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