Conditions | 10 |
Paths | 9 |
Total Lines | 31 |
Code Lines | 15 |
Lines | 0 |
Ratio | 0 % |
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 |
||
98 | protected function getType(&$value) |
||
99 | { |
||
100 | $type = self::T_NONE; |
||
101 | |||
102 | if ($value[0] === '"') { |
||
103 | $value = str_replace('""', '"', substr($value, 1, strlen($value) - 2)); |
||
104 | |||
105 | return self::T_STRING; |
||
106 | } |
||
107 | |||
108 | if (isset($this->noCase[$value])) { |
||
109 | return $this->noCase[$value]; |
||
110 | } |
||
111 | |||
112 | if ($value[0] === '_' || $value[0] === '\\' || ctype_alpha($value[0])) { |
||
113 | return self::T_IDENTIFIER; |
||
114 | } |
||
115 | |||
116 | $lowerValue = strtolower($value); |
||
117 | |||
118 | if (isset($this->withCase[$lowerValue])) { |
||
119 | return $this->withCase[$lowerValue]; |
||
120 | } |
||
121 | |||
122 | // Checking numeric value |
||
123 | if (is_numeric($value)) { |
||
124 | return (strpos($value, '.') !== false || stripos($value, 'e') !== false) |
||
125 | ? self::T_FLOAT : self::T_INTEGER; |
||
126 | } |
||
127 | |||
128 | return $type; |
||
129 | } |
||
131 |