| Total Complexity | 8 |
| Total Lines | 89 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 8 | class ClosureParser implements ParserActionInterface |
||
| 9 | { |
||
| 10 | /** |
||
| 11 | * @var Illuminate\Routing\Route |
||
|
|
|||
| 12 | */ |
||
| 13 | protected $route; |
||
| 14 | |||
| 15 | /** |
||
| 16 | * @var array |
||
| 17 | */ |
||
| 18 | protected $content = []; |
||
| 19 | |||
| 20 | /** |
||
| 21 | * @var array |
||
| 22 | */ |
||
| 23 | protected $errors = []; |
||
| 24 | |||
| 25 | /** |
||
| 26 | * @param Route $route |
||
| 27 | */ |
||
| 28 | public function __construct(Route $route) |
||
| 29 | { |
||
| 30 | $this->route = $route; |
||
| 31 | } |
||
| 32 | |||
| 33 | /** |
||
| 34 | * @return TypeHints\Unused\Parser\Action\ParserActionInterface |
||
| 35 | */ |
||
| 36 | public function parse(): ParserActionInterface |
||
| 37 | { |
||
| 38 | $this->content = $this->fetchContent(); |
||
| 39 | |||
| 40 | return $this; |
||
| 41 | } |
||
| 42 | |||
| 43 | /** |
||
| 44 | * @return ReflectionFunction |
||
| 45 | */ |
||
| 46 | protected function resolveMethod(): ReflectionFunction |
||
| 47 | { |
||
| 48 | return new ReflectionFunction($this->getClosure()); |
||
| 49 | } |
||
| 50 | |||
| 51 | /** |
||
| 52 | * @return array |
||
| 53 | */ |
||
| 54 | protected function fetchContent(): array |
||
| 55 | { |
||
| 56 | $method = $this->resolveMethod(); |
||
| 57 | |||
| 58 | return array_slice( |
||
| 59 | file($method->getFileName()), |
||
| 60 | $method->getStartLine() - 1, |
||
| 61 | $method->getEndLine() - $method->getStartLine() + 1 |
||
| 62 | ); |
||
| 63 | } |
||
| 64 | |||
| 65 | /** |
||
| 66 | * @return array |
||
| 67 | */ |
||
| 68 | public function getContent(): array |
||
| 71 | } |
||
| 72 | |||
| 73 | /** |
||
| 74 | * @return array |
||
| 75 | */ |
||
| 76 | public function getErrors(): array |
||
| 77 | { |
||
| 78 | return $this->errors; |
||
| 79 | } |
||
| 80 | |||
| 81 | /** |
||
| 82 | * @return callable |
||
| 83 | */ |
||
| 84 | public function getClosure(): callable |
||
| 85 | { |
||
| 86 | return $this->route->getAction('uses'); |
||
| 87 | } |
||
| 88 | |||
| 89 | /** |
||
| 90 | * @return array |
||
| 91 | */ |
||
| 92 | public function getRoute(): array |
||
| 97 | ]); |
||
| 98 | } |
||
| 99 | } |
||
| 100 |