| Conditions | 10 |
| Paths | 45 |
| Total Lines | 28 |
| Code Lines | 16 |
| Lines | 16 |
| Ratio | 57.14 % |
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 /** MicroAsset */ |
||
| 89 | public function publish() |
||
| 90 | { |
||
| 91 | foreach ($this->required AS $require) { |
||
| 92 | if (!in_array($require, $this->published, true) && class_exists($require)) { |
||
| 93 | $this->published[] = $require; |
||
| 94 | /** @var Asset $require */ |
||
| 95 | $require = new $require($this->view); |
||
| 96 | $require->publish(); |
||
| 97 | } |
||
| 98 | } |
||
| 99 | |||
| 100 | View Code Duplication | if ($this->js) { |
|
| 101 | if (is_string($this->js)) { |
||
| 102 | $this->js = [$this->js]; |
||
| 103 | } |
||
| 104 | foreach ($this->js AS $script) { |
||
| 105 | $this->view->registerScriptFile($this->publishPath . $script, $this->isHead); |
||
| 106 | } |
||
| 107 | } |
||
| 108 | View Code Duplication | if ($this->css) { |
|
| 109 | if (is_string($this->css)) { |
||
| 110 | $this->css = [$this->css]; |
||
| 111 | } |
||
| 112 | foreach ($this->css AS $style) { |
||
| 113 | $this->view->registerCssFile($this->publishPath . $style, $this->isHead); |
||
| 114 | } |
||
| 115 | } |
||
| 116 | } |
||
| 117 | } |
||
| 118 |
If you access a property on an interface, you most likely code against a concrete implementation of the interface.
Available Fixes
Adding an additional type check:
Changing the type hint: