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