| Conditions | 11 |
| Paths | 192 |
| Total Lines | 36 |
| Code Lines | 21 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 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 |
||
| 38 | public function getErrors(): array |
||
| 39 | { |
||
| 40 | $errors = []; |
||
| 41 | |||
| 42 | if (! $this->entityNamespace) { |
||
| 43 | $errors[] = 'Missing entity namespace property'; |
||
| 44 | } |
||
| 45 | |||
| 46 | if (! $this->entityDestination) { |
||
| 47 | $errors[] = 'Missing entity destination property'; |
||
| 48 | } elseif (! is_dir($this->entityDestination)) { |
||
| 49 | $errors[] = sprintf('%s is not a valid directory', $this->entityDestination); |
||
| 50 | } elseif (! is_writable($this->entityDestination)) { |
||
| 51 | $errors[] = sprintf('%s is not writable', $this->entityDestination); |
||
| 52 | } |
||
| 53 | |||
| 54 | if (! $this->mapperNamespace) { |
||
| 55 | $errors[] = 'Missing mapper namespace property'; |
||
| 56 | } |
||
| 57 | |||
| 58 | if (! $this->mapperDestination) { |
||
| 59 | $errors[] = 'Missing entity destination property'; |
||
| 60 | } elseif (! is_dir($this->mapperDestination)) { |
||
| 61 | $errors[] = sprintf('%s is not a valid directory', $this->mapperDestination); |
||
| 62 | } elseif (! is_writable($this->mapperDestination)) { |
||
| 63 | $errors[] = sprintf('%s is not writable', $this->mapperDestination); |
||
| 64 | } |
||
| 65 | |||
| 66 | /** @var Mapper $mapper */ |
||
| 67 | foreach ($this->mappers as $name => $mapper) { |
||
| 68 | foreach ($mapper->getErrors() as $error) { |
||
| 69 | $errors[] = sprintf('Mapper %s: %s', $name, $error); |
||
| 70 | } |
||
| 71 | } |
||
| 72 | |||
| 73 | return $errors; |
||
| 74 | } |
||
| 179 |