Conditions | 5 |
Paths | 5 |
Total Lines | 13 |
Code Lines | 8 |
Lines | 0 |
Ratio | 0 % |
Tests | 9 |
CRAP Score | 5 |
Changes | 0 |
1 | <?php |
||
46 | 1 | final public function calculateSort(?bool $sortLast = null): int |
|
47 | { |
||
48 | /* @var $collection Collection|SortableInterface[] */ |
||
49 | 1 | $collection = $this->getSortCollection(); |
|
50 | 1 | if (null === $sortLast) { |
|
51 | 1 | return 0; |
|
52 | } |
||
53 | 1 | if ($sortLast) { |
|
54 | 1 | $lastItem = $collection->last(); |
|
55 | 1 | return $lastItem ? ($lastItem->getSort() + 1) : 0; |
|
56 | } |
||
57 | 1 | $firstItem = $collection->first(); |
|
58 | 1 | return $firstItem ? ($firstItem->getSort() - 1) : 0; |
|
59 | } |
||
66 |