Conditions | 12 |
Paths | 11 |
Total Lines | 45 |
Code Lines | 33 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 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 |
||
60 | private function injectEGPCSToGlobal() |
||
61 | { |
||
62 | $injectedFlag = array( |
||
63 | 'e' => false, |
||
64 | 'g' => false, |
||
65 | 'p' => false, |
||
66 | 'c' => false, |
||
67 | 's' => false |
||
68 | ); |
||
69 | |||
70 | foreach ($this->getInjectVariables() as $name) { |
||
71 | if (!isset($injectedFlag[$name]) || $injectedFlag[$name]) { |
||
72 | continue; |
||
73 | } |
||
74 | |||
75 | switch ($name) { |
||
76 | case 'e': |
||
77 | $this->injectToGlobal($_ENV); |
||
78 | break; |
||
79 | case 'g': |
||
80 | if ($this->magicQuotesGpc) { |
||
81 | $this->addSlashesRecursive($_GET); |
||
82 | } |
||
83 | $this->injectToGlobal($_GET); |
||
84 | break; |
||
85 | case 'p': |
||
86 | if ($this->magicQuotesGpc) { |
||
87 | $this->addSlashesRecursive($_POST); |
||
88 | } |
||
89 | $this->injectToGlobal($_POST); |
||
90 | break; |
||
91 | case 'c': |
||
92 | if ($this->magicQuotesGpc) { |
||
93 | $this->addSlashesRecursive($_COOKIE); |
||
94 | } |
||
95 | $this->injectToGlobal($_COOKIE); |
||
96 | break; |
||
97 | case 's': |
||
98 | $this->injectToGlobal($_SERVER); |
||
99 | break; |
||
100 | } |
||
101 | |||
102 | $injectedFlag[$name] = true; |
||
103 | } |
||
104 | } |
||
105 | |||
140 |