| Total Complexity | 10 |
| Total Lines | 42 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 18 | class RouteListItem implements Arrayable |
||
| 19 | { |
||
| 20 | protected Route $route; |
||
| 21 | |||
| 22 | public function __construct(Route $route) |
||
| 23 | { |
||
| 24 | $this->route = $route; |
||
| 25 | } |
||
| 26 | |||
| 27 | public function toArray(): array |
||
| 28 | { |
||
| 29 | return [ |
||
|
|
|||
| 30 | 'page_type' => $this->stylePageType($this->route->getPageClass()), |
||
| 31 | 'source_file' => $this->styleSourcePath($this->route->getSourcePath()), |
||
| 32 | 'output_file' => $this->styleOutputPath($this->route->getOutputPath()), |
||
| 33 | 'route_key' => $this->styleRouteKey($this->route->getRouteKey()), |
||
| 34 | ]; |
||
| 35 | } |
||
| 36 | |||
| 37 | protected function stylePageType(string $class): string |
||
| 38 | { |
||
| 39 | return str_starts_with($class, 'Hyde') ? class_basename($class) : $class; |
||
| 40 | } |
||
| 41 | |||
| 42 | protected function styleSourcePath(string $path): string |
||
| 43 | { |
||
| 44 | return $this->isPageDiscoverable() ? $path : 'none'; |
||
| 45 | } |
||
| 46 | |||
| 47 | protected function styleOutputPath(string $path): string |
||
| 50 | } |
||
| 51 | |||
| 52 | protected function styleRouteKey(string $key): string |
||
| 55 | } |
||
| 56 | |||
| 57 | protected function isPageDiscoverable(): bool |
||
| 58 | { |
||
| 62 |
In the issue above, the returned value is violating the contract defined by the mentioned interface.
Let's take a look at an example: