| Conditions | 10 |
| Paths | 257 |
| Total Lines | 26 |
| Code Lines | 17 |
| 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 |
||
| 45 | final public function loadPlugin(EnvironmentInterface $environment): void |
||
| 46 | { |
||
| 47 | foreach ($this->objects as $item) { |
||
| 48 | if ($item instanceof ApiVersionConstraint) { |
||
| 49 | $environment->assertApiVersion($item); |
||
| 50 | } |
||
| 51 | if ($item instanceof CommandInterface) { |
||
| 52 | $environment->registerCommand($item); |
||
| 53 | } |
||
| 54 | if ($item instanceof EventSubscriberInterface) { |
||
| 55 | $environment->registerSubscriber($item); |
||
| 56 | } |
||
| 57 | if ($item instanceof FilterInterface) { |
||
| 58 | $environment->registerDonorFilter($item); |
||
| 59 | } |
||
| 60 | if ($item instanceof FormatterInterface) { |
||
| 61 | $environment->registerDonorFormatter($item); |
||
| 62 | } |
||
| 63 | if ($item instanceof SorterInterface) { |
||
| 64 | $environment->registerDonorSorter($item); |
||
| 65 | } |
||
| 66 | if ($item instanceof StateInterface) { |
||
| 67 | $environment->registerDonorState($item); |
||
| 68 | } |
||
| 69 | if ($item instanceof XmlFormInterface) { |
||
| 70 | $environment->registerXmlForm($item); |
||
| 71 | } |
||
| 75 |