| Conditions | 13 |
| Paths | 8 |
| Total Lines | 33 |
| Code Lines | 18 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 6 | ||
| Bugs | 2 | Features | 2 |
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 |
||
| 35 | public function init($filters = array(), $filterFile = '', $exclusive = array()) |
||
| 36 | { |
||
| 37 | if (count($exclusive) > 0 && (count($filters) > 0 || $filterFile !== '')) { |
||
| 38 | throw new \RuntimeException("It's not possible to define filter lists and an exclusive list at the same time [Extension: " . get_class($this) . '].'); |
||
| 39 | } |
||
| 40 | |||
| 41 | if ($filterFile !== '') { |
||
| 42 | if (!file_exists($filterFile)) { |
||
| 43 | throw new \RuntimeException('Filter file not found: ' . $filterFile); |
||
| 44 | } |
||
| 45 | |||
| 46 | $filterElements = EnvAwareYaml::parse(file_get_contents($filterFile)); |
||
| 47 | |||
| 48 | foreach ($filterElements['filters'] as $rule => $uris) { |
||
| 49 | foreach ($uris as $uri) { |
||
| 50 | $this->filters[] = array('rule' => $rule, 'uri' => $uri); |
||
| 51 | } |
||
| 52 | } |
||
| 53 | } elseif (!is_null($filters)) { |
||
| 54 | foreach ($filters as $rule => $filteredUrls) { |
||
| 55 | if (!is_null($filteredUrls)) { |
||
| 56 | foreach ($filteredUrls as $uri) { |
||
| 57 | $this->filters[] = array('rule' => $rule, 'uri' => $uri); |
||
| 58 | } |
||
| 59 | } |
||
| 60 | } |
||
| 61 | } |
||
| 62 | |||
| 63 | if (count($exclusive) > 0) { |
||
| 64 | $this->exclusives = $exclusive; |
||
| 65 | $this->currentModus = self::MODUS_EXCLUSIVE; |
||
| 66 | } |
||
| 67 | } |
||
| 68 | |||
| 111 |