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