We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.
Complex classes like NestedValidationException often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes. You can also have a look at the cohesion graph to spot any un-connected, or weakly-connected components.
Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.
While breaking up the class, it is a good idea to analyze how other classes use NestedValidationException, and based on these observations, apply Extract Interface, too.
| 1 | <?php |
||
| 18 | class NestedValidationException extends ValidationException implements IteratorAggregate |
||
| 19 | { |
||
| 20 | /** |
||
| 21 | * @var SplObjectStorage |
||
| 22 | */ |
||
| 23 | private $exceptions = []; |
||
| 24 | |||
| 25 | /** |
||
| 26 | * @param ValidationException $exception |
||
| 27 | * |
||
| 28 | * @return self |
||
| 29 | */ |
||
| 30 | 3 | public function addRelated(ValidationException $exception) |
|
| 36 | |||
| 37 | /** |
||
| 38 | * @param string $path |
||
| 39 | * @param ValidationException $exception |
||
| 40 | * |
||
| 41 | * @return ValidationException |
||
| 42 | */ |
||
| 43 | private function getExceptionForPath($path, ValidationException $exception) |
||
| 57 | |||
| 58 | /** |
||
| 59 | * @param array $paths |
||
| 60 | * |
||
| 61 | * @return self |
||
| 62 | */ |
||
| 63 | public function findMessages(array $paths) |
||
| 92 | |||
| 93 | /** |
||
| 94 | * @return Exception |
||
| 95 | */ |
||
| 96 | 1 | public function findRelated($path) |
|
| 108 | |||
| 109 | /** |
||
| 110 | * @return RecursiveIteratorIterator |
||
| 111 | */ |
||
| 112 | 1 | private function getRecursiveIterator() |
|
| 122 | |||
| 123 | /** |
||
| 124 | * @return SplObjectStorage |
||
| 125 | */ |
||
| 126 | public function getIterator() |
||
| 173 | |||
| 174 | /** |
||
| 175 | * @return array |
||
| 176 | */ |
||
| 177 | public function getMessages() |
||
| 190 | |||
| 191 | /** |
||
| 192 | * @return string |
||
| 193 | */ |
||
| 194 | public function getFullMessage() |
||
| 212 | |||
| 213 | /** |
||
| 214 | * @return SplObjectStorage |
||
| 215 | */ |
||
| 216 | 3 | public function getRelated() |
|
| 224 | |||
| 225 | /** |
||
| 226 | * @param string $name |
||
| 227 | * @param mixed $value |
||
| 228 | * |
||
| 229 | * @return self |
||
| 230 | */ |
||
| 231 | public function setParam($name, $value) |
||
| 243 | |||
| 244 | /** |
||
| 245 | * @return bool |
||
| 246 | */ |
||
| 247 | 1 | private function isRelated($name, ValidationException $exception) |
|
| 251 | |||
| 252 | /** |
||
| 253 | * @return ValidationException |
||
| 254 | */ |
||
| 255 | 1 | public function getRelatedByName($name) |
|
| 267 | |||
| 268 | /** |
||
| 269 | * @param array $exceptions |
||
| 270 | * |
||
| 271 | * @return self |
||
| 272 | */ |
||
| 273 | public function setRelated(array $exceptions) |
||
| 281 | } |
||
| 282 |