Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
5 / 5 |
|
100.00% |
3 / 3 |
CRAP | |
100.00% |
1 / 1 |
| DocumentationSidebar | |
100.00% |
5 / 5 |
|
100.00% |
3 / 3 |
3 | |
100.00% |
1 / 1 |
| addItem | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
1 | |||
| sortItems | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
1 | |||
| getCollection | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| 1 | <?php |
| 2 | |
| 3 | namespace Hyde\Framework\Models; |
| 4 | |
| 5 | use Hyde\Framework\Contracts\DocumentationSidebarContract; |
| 6 | use Illuminate\Support\Collection; |
| 7 | |
| 8 | /** |
| 9 | * The documentation sidebar, containing all the sidebar items. |
| 10 | * |
| 11 | * Extends the \Illuminate\Support\Collection class and has helper |
| 12 | * methods to fluently add DocumentationSidebarItems to the |
| 13 | * collection using method chaining. |
| 14 | * |
| 15 | * @see \Tests\Feature\Services\DocumentationSidebarServiceTest |
| 16 | */ |
| 17 | class DocumentationSidebar extends Collection implements DocumentationSidebarContract |
| 18 | { |
| 19 | public function addItem(DocumentationSidebarItem $item): self |
| 20 | { |
| 21 | $this->push($item); |
| 22 | |
| 23 | return $this; |
| 24 | } |
| 25 | |
| 26 | public function sortItems(): self |
| 27 | { |
| 28 | return $this->sortBy('priority') |
| 29 | ->values(); // Reset the keys to consecutively numbered indexes: |
| 30 | } |
| 31 | |
| 32 | public function getCollection(): self |
| 33 | { |
| 34 | return $this; |
| 35 | } |
| 36 | } |