Skip to content

Commit

Permalink
not return self in adjustment methods
Browse files Browse the repository at this point in the history
  • Loading branch information
peter-gribanov committed Mar 31, 2017
1 parent 1b90378 commit 1f886de
Showing 1 changed file with 4 additions and 21 deletions.
25 changes: 4 additions & 21 deletions src/Service/NavigateRange.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,33 +56,26 @@ public function getRightOffset()
private function buildOffset()
{
if ($this->left_offset < 0) {
$this
->definitionOffset()
->adjustmentLargeLeftOffset()
->adjustmentLargeRightOffset()
->adjustmentLowerLeftOffset();
$this->definitionOffset();
$this->adjustmentLargeLeftOffset();
$this->adjustmentLargeRightOffset();
$this->adjustmentLowerLeftOffset();
}

return $this;
}

/**
* Definition of offset to the left and to the right of the selected page.
*
* @return self
*/
private function definitionOffset()
{
$this->left_offset = (int) floor(($this->config->getMaxNavigate() - 1) / 2);
$this->right_offset = (int) ceil(($this->config->getMaxNavigate() - 1) / 2);

return $this;
}

/**
* Adjustment, if the offset is too large left.
*
* @return self
*/
private function adjustmentLargeLeftOffset()
{
Expand All @@ -91,14 +84,10 @@ private function adjustmentLargeLeftOffset()
$this->left_offset = $this->left_offset - $offset;
$this->right_offset = $this->right_offset + $offset;
}

return $this;
}

/**
* Adjustment, if the offset is too large right.
*
* @return self
*/
private function adjustmentLargeRightOffset()
{
Expand All @@ -111,21 +100,15 @@ private function adjustmentLargeRightOffset()
$this->left_offset = $this->left_offset + $offset;
$this->right_offset = $this->right_offset - $offset;
}

return $this;
}

/**
* Left offset should point not lower of the first page.
*
* @return self
*/
private function adjustmentLowerLeftOffset()
{
if ($this->left_offset >= $this->config->getCurrentPage()) {
$this->left_offset = $this->config->getCurrentPage() - 1;
}

return $this;
}
}

0 comments on commit 1f886de

Please sign in to comment.