| Conditions | 15 |
| Paths | 16 |
| Total Lines | 37 |
| 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 |
||
| 20 | public function match($body) |
||
| 21 | { |
||
| 22 | if ($this->swaggerSchema->getSpecificationVersion() === '3') { |
||
| 23 | if (isset($this->structure['content']) || isset($this->structure['$ref'])) { |
||
| 24 | if (isset($this->structure['required']) && $this->structure['required'] === true && empty($body)) { |
||
| 25 | throw new RequiredArgumentNotFound('The body is required but it is empty'); |
||
| 26 | } |
||
| 27 | |||
| 28 | if (isset($this->structure['$ref'])) { |
||
| 29 | return $this->matchSchema($this->name, $this->structure, $body); |
||
| 30 | } |
||
| 31 | |||
| 32 | return $this->matchSchema($this->name, $this->structure['content'][key($this->structure['content'])]['schema'], $body); |
||
| 33 | } |
||
| 34 | |||
| 35 | if (!empty($body)) { |
||
| 36 | throw new InvalidDefinitionException('Body is passed but there is no request body definition'); |
||
| 37 | } |
||
| 38 | } |
||
| 39 | |||
| 40 | foreach ($this->structure as $parameter) { |
||
| 41 | if ($parameter['in'] == "body") { |
||
| 42 | if (isset($parameter['required']) && $parameter['required'] === true && empty($body)) { |
||
| 43 | throw new RequiredArgumentNotFound('The body is required but it is empty'); |
||
| 44 | } |
||
| 45 | return $this->matchSchema($this->name, $parameter['schema'], $body); |
||
| 46 | } |
||
| 47 | } |
||
| 48 | |||
| 49 | if (!empty($body)) { |
||
| 50 | throw new InvalidDefinitionException('Body is passed but there is no request body definition'); |
||
| 51 | } |
||
| 52 | |||
| 53 | |||
| 54 | |||
| 55 | return false; |
||
| 56 | } |
||
| 57 | } |
||
| 58 |