Conditions | 11 |
Paths | 7 |
Total Lines | 21 |
Code Lines | 14 |
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 |
||
63 | protected function validateArguments(string $parameterIn, array $parameters, array $arguments): void |
||
64 | { |
||
65 | foreach ($parameters as $parameter) { |
||
66 | if (isset($parameter['$ref'])) { |
||
67 | $paramParts = explode("/", $parameter['$ref']); |
||
68 | if (count($paramParts) != 4 || $paramParts[0] != "#" || $paramParts[1] != self::SWAGGER_COMPONENTS || $paramParts[2] != self::SWAGGER_PARAMETERS) { |
||
69 | throw new InvalidDefinitionException( |
||
70 | "Not get the reference in the expected format #/components/parameters/<NAME>" |
||
71 | ); |
||
72 | } |
||
73 | if (!isset($this->jsonFile[self::SWAGGER_COMPONENTS][self::SWAGGER_PARAMETERS][$paramParts[3]])) { |
||
74 | throw new DefinitionNotFoundException( |
||
75 | "Not find reference #/components/parameters/$paramParts[3]" |
||
76 | ); |
||
77 | } |
||
78 | $parameter = $this->jsonFile[self::SWAGGER_COMPONENTS][self::SWAGGER_PARAMETERS][$paramParts[3]]; |
||
79 | } |
||
80 | if ($parameter['in'] === $parameterIn && |
||
81 | $parameter['schema']['type'] === "integer" |
||
82 | && filter_var($arguments[$parameter['name']], FILTER_VALIDATE_INT) === false) { |
||
83 | throw new NotMatchedException('Path expected an integer value'); |
||
84 | } |
||
136 |