Conditions | 13 |
Paths | 96 |
Total Lines | 43 |
Lines | 18 |
Ratio | 41.86 % |
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 |
||
28 | public function init() |
||
29 | { |
||
30 | $this->header('Content-Type: text/html'); // default header. |
||
31 | |||
32 | $this->proc = new \PHPDaemon\Core\ShellCommand(); |
||
33 | $this->proc->readPacketSize = $this->appInstance->readPacketSize; |
||
34 | $this->proc->onReadData([$this, 'onReadData']); |
||
35 | $this->proc->onWrite([$this, 'onWrite']); |
||
36 | $this->proc->binPath = $this->appInstance->binPath; |
||
37 | $this->proc->chroot = $this->appInstance->chroot; |
||
38 | |||
39 | if (isset($this->attrs->server['BINPATH'])) { |
||
40 | if (isset($this->appInstance->binAliases[$this->attrs->server['BINPATH']])) { |
||
41 | $this->proc->binPath = $this->appInstance->binAliases[$this->attrs->server['BINPATH']]; |
||
42 | } elseif ($this->appInstance->config->allowoverridebinpath->value) { |
||
43 | $this->proc->binPath = $this->attrs->server['BINPATH']; |
||
44 | } |
||
45 | } |
||
46 | |||
47 | View Code Duplication | if (isset($this->attrs->server['CHROOT']) && $this->appInstance->config->allowoverridechroot->value) { |
|
48 | $this->proc->chroot = $this->attrs->server['CHROOT']; |
||
49 | } |
||
50 | |||
51 | View Code Duplication | if (isset($this->attrs->server['SETUSER']) && $this->appInstance->config->allowoverrideuser->value) { |
|
52 | $this->proc->setUser = $this->attrs->server['SETUSER']; |
||
53 | } |
||
54 | |||
55 | View Code Duplication | if (isset($this->attrs->server['SETGROUP']) && $this->appInstance->config->allowoverridegroup->value) { |
|
56 | $this->proc->setGroup = $this->attrs->server['SETGROUP']; |
||
57 | } |
||
58 | |||
59 | if (isset($this->attrs->server['CWD']) && $this->appInstance->config->allowoverridecwd->value) { |
||
60 | $this->proc->cwd = $this->attrs->server['CWD']; |
||
61 | } elseif ($this->appInstance->config->cwd->value !== null) { |
||
62 | $this->proc->cwd = $this->appInstance->config->cwd->value; |
||
63 | } else { |
||
64 | $this->proc->cwd = dirname($this->attrs->server['SCRIPT_FILENAME']); |
||
65 | } |
||
66 | |||
67 | $this->proc->setArgs([$this->attrs->server['SCRIPT_FILENAME']]); |
||
68 | $this->proc->setEnv($this->attrs->server); |
||
69 | $this->proc->execute(); |
||
70 | } |
||
71 | |||
136 |
Since your code implements the magic setter
_set
, this function will be called for any write access on an undefined variable. You can add the@property
annotation to your class or interface to document the existence of this variable.Since the property has write access only, you can use the @property-write annotation instead.
Of course, you may also just have mistyped another name, in which case you should fix the error.
See also the PhpDoc documentation for @property.