| Conditions | 1 |
| Paths | 1 |
| Total Lines | 52 |
| Code Lines | 27 |
| 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 |
||
| 86 | public function postBind(array $configuration) |
||
| 87 | { |
||
| 88 | $this->container->instance('config', $configuration); |
||
| 89 | |||
| 90 | // Setup AnalysisException ComplexityComputing |
||
| 91 | AnalysisException::setComplexityComputer($this->container['complexity-computer']); |
||
| 92 | |||
| 93 | $this->container->bind('message-provider', function ($container) { |
||
| 94 | return new MessageProvider($container['config']); |
||
| 95 | }); |
||
| 96 | |||
| 97 | $this->container->bind('flaw-detector', function ($container) { |
||
| 98 | return new FlawDetector($container['bootstrapper'], $container['config']); |
||
| 99 | }); |
||
| 100 | |||
| 101 | $this->container->bind('analyzer', function ($container) { |
||
| 102 | return $this->bootstrap( |
||
| 103 | new Analyzer( |
||
| 104 | $container['parser'], |
||
| 105 | $container['flaw-detector'] |
||
| 106 | ) |
||
| 107 | ); |
||
| 108 | }); |
||
| 109 | |||
| 110 | $this->container->bind(FeedbackInterface::class, function ($container) { |
||
| 111 | return new ConsolePlainFeedback($container['config'], $container['output']); |
||
| 112 | }); |
||
| 113 | |||
| 114 | $this->container->bind('report-generator', function ($container) { |
||
| 115 | return new ReportGenerator($container['filesystem']); |
||
| 116 | }); |
||
| 117 | |||
| 118 | $this->container->bind('report-service', function ($container) { |
||
| 119 | return new ReportService($container['report-generator']); |
||
| 120 | }); |
||
| 121 | |||
| 122 | $this->container->bind('analyzer-service', function ($container) { |
||
| 123 | return new AnalyzerService( |
||
| 124 | $container['analyzer'], |
||
| 125 | $container['code-scanner'], |
||
| 126 | $container[FeedbackInterface::class], |
||
| 127 | $container['report-service'] |
||
| 128 | ); |
||
| 129 | }); |
||
| 130 | |||
| 131 | $this->container->bind(InspectCommand::class, function ($container) { |
||
| 132 | return new InspectCommand( |
||
| 133 | $container['analyzer-service'] |
||
| 134 | ); |
||
| 135 | }); |
||
| 136 | |||
| 137 | } |
||
| 138 | |||
| 149 |
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: