Conditions | 13 |
Paths | 64 |
Total Lines | 31 |
Code Lines | 16 |
Lines | 0 |
Ratio | 0 % |
Changes | 2 | ||
Bugs | 0 | Features | 1 |
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 |
||
55 | public function __construct(array $config = [], FileSystem $filesystem = null) |
||
56 | { |
||
57 | if (!$filesystem) { |
||
58 | $filesystem = new FileSystem(); |
||
59 | } |
||
60 | |||
61 | $this->fileSystem = $filesystem; |
||
62 | |||
63 | if (isset($config['phpPath']) && !empty($config['phpPath'])) { |
||
64 | $this->phpPath = $config['phpPath']; |
||
65 | } |
||
66 | |||
67 | if (isset($config['scriptPath']) && !empty($config['scriptPath'])) { |
||
68 | $this->scriptPath = $config['scriptPath']; |
||
69 | } |
||
70 | |||
71 | if (isset($config['jobs']) && !empty($config['jobs']) && is_array($config['jobs'])) { |
||
72 | $this->jobs = $config['jobs']; |
||
73 | } |
||
74 | |||
75 | if (isset($config['timeout']) && !empty($config['timeout'])) { |
||
76 | $this->timeout = $config['timeout']; |
||
77 | } |
||
78 | |||
79 | $logDirectory = null; |
||
80 | if (isset($config['log-directory']) && !empty($config['log-directory'])) { |
||
81 | $logDirectory = $config['log-directory']; |
||
82 | } |
||
83 | |||
84 | $this->logDirectory = $this->prepareLogDirectory($logDirectory); |
||
85 | } |
||
86 | |||
162 |