| 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 |
||
| 41 | public function init($filters = array(), $filterFile = '', $exclusive = array()) |
||
| 42 | { |
||
| 43 | if (count($exclusive) > 0 && (count($filters) > 0 || $filterFile !== '')) { |
||
| 44 | throw new \RuntimeException("It's not possible to define filter lists and an exclusive list at the same time [Extension: " . get_class($this) . '].'); |
||
| 45 | } |
||
| 46 | |||
| 47 | if ($filterFile !== '') { |
||
| 48 | if (!file_exists($filterFile)) { |
||
| 49 | throw new \RuntimeException('Filter file not found: ' . $filterFile); |
||
| 50 | } |
||
| 51 | |||
| 52 | $filterElements = EnvAwareYaml::parse(file_get_contents($filterFile)); |
||
| 53 | |||
| 54 | foreach ($filterElements['filters'] as $rule => $uris) { |
||
| 55 | foreach ($uris as $uri) { |
||
| 56 | $this->filters[] = array('rule' => $rule, 'uri' => $uri); |
||
| 57 | } |
||
| 58 | } |
||
| 59 | } elseif (!is_null($filters)) { |
||
| 60 | foreach ($filters as $rule => $filteredUrls) { |
||
| 61 | if (!is_null($filteredUrls)) { |
||
| 62 | foreach ($filteredUrls as $uri) { |
||
| 63 | $this->filters[] = array('rule' => $rule, 'uri' => $uri); |
||
| 64 | } |
||
| 65 | } |
||
| 66 | } |
||
| 67 | } |
||
| 68 | |||
| 69 | if (count($exclusive) > 0) { |
||
| 70 | $this->exclusives = $exclusive; |
||
| 71 | $this->currentModus = self::MODUS_EXCLUSIVE; |
||
| 72 | } |
||
| 73 | } |
||
| 74 | |||
| 129 |