| Conditions | 11 |
| Paths | 15 |
| Total Lines | 62 |
| Code Lines | 32 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
| 1 | <?php |
||
| 52 | public function handle(string $routeName, Crawler $crawler, Client $client, array $options = []): void |
||
| 53 | { |
||
| 54 | $configuration = $this->getConfiguration($routeName); |
||
| 55 | $mapping = $this->mappingResolver->resolve($this->getMappingName($routeName), $routeName); |
||
| 56 | |||
| 57 | foreach ($configuration as $selector => $content) { |
||
| 58 | if ($this->isDynamicString($content)) { |
||
| 59 | /** @var Response $response */ |
||
| 60 | $response = $client->getResponse(); |
||
| 61 | $requirements = []; |
||
| 62 | /** @var UrlInfo $test */ |
||
| 63 | $test = $options['url_info']; |
||
| 64 | //$response->getHeader(); |
||
| 65 | |||
| 66 | foreach ($this->requirementsProviderRegistry->all() as $requirementsProvider) { |
||
| 67 | if (!$requirementsProvider->supports($routeName)) { |
||
| 68 | continue; |
||
| 69 | } |
||
| 70 | $criteria = []; |
||
| 71 | $requirements = array_merge($requirements, $requirementsProvider->getRequirements($routeName)); |
||
| 72 | |||
| 73 | foreach ($requirementsProvider->getRequirements($routeName) as $requirement => $default) { |
||
| 74 | if (!key_exists($requirement, $test->getExtra())) { |
||
| 75 | continue; |
||
| 76 | } |
||
| 77 | $criteria[$requirement] = $test->getExtra()[$requirement]; |
||
| 78 | } |
||
| 79 | |||
| 80 | $lol = $requirementsProvider->getRequirementsData($routeName, [ |
||
| 81 | 'where' => $criteria, |
||
| 82 | ]); |
||
| 83 | var_dump($criteria); |
||
| 84 | |||
| 85 | foreach ($lol as $item) { |
||
| 86 | var_dump($item); |
||
| 87 | |||
| 88 | } |
||
| 89 | die; |
||
| 90 | } |
||
| 91 | |||
| 92 | $criteria = []; |
||
| 93 | // var_dump($requirements); |
||
| 94 | // die('ko'); |
||
| 95 | |||
| 96 | //$t = $this->urlProviderRegistry->match(); |
||
| 97 | |||
| 98 | foreach ($requirements as $requirement => $default) { |
||
| 99 | if (!key_exists($requirement, $test->getExtra())) { |
||
| 100 | continue; |
||
| 101 | } |
||
| 102 | $criteria[$requirement] = $test->getExtra()[$requirement]; |
||
| 103 | } |
||
| 104 | |||
| 105 | var_dump($criteria); |
||
| 106 | die; |
||
| 107 | // $provider = $this->registry->get('default'); |
||
| 108 | // $provider->getRequirements($routeName, [ |
||
| 109 | // 'where' => '', |
||
| 110 | // ]); |
||
| 111 | } else { |
||
| 112 | if (false === strpos($crawler->filter($selector)->text(), $content)) { |
||
| 113 | throw new Exception(); |
||
| 114 | } |
||
| 142 |