| Conditions | 14 |
| Paths | 19 |
| Total Lines | 35 |
| Code Lines | 24 |
| Lines | 26 |
| Ratio | 74.29 % |
| 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 |
||
| 35 | public function __construct() |
||
| 36 | { |
||
| 37 | parent::__construct(); |
||
| 38 | switch (defined('PSI_SENSOR_SPEEDFAN_ACCESS')?strtolower(PSI_SENSOR_SPEEDFAN_ACCESS):'command') { |
||
| 39 | View Code Duplication | case 'command': |
|
| 40 | if (CommonFunctions::executeProgram("SpeedFanGet.exe", "", $buffer, PSI_DEBUG) && (strlen($buffer) > 0)) { |
||
| 41 | if (preg_match("/^Temperatures:\s+(.+)$/m", $buffer, $out)) { |
||
| 42 | $this->_filecontent["temp"] = $out[1]; |
||
| 43 | } |
||
| 44 | if (preg_match("/^Fans:\s+(.+)$/m", $buffer, $out)) { |
||
| 45 | $this->_filecontent["fans"] = $out[1]; |
||
| 46 | } |
||
| 47 | if (preg_match("/^Voltages:\s+(.+)$/m", $buffer, $out)) { |
||
| 48 | $this->_filecontent["volt"] = $out[1]; |
||
| 49 | } |
||
| 50 | } |
||
| 51 | break; |
||
| 52 | View Code Duplication | case 'data': |
|
| 53 | if (CommonFunctions::rfts(APP_ROOT.'/data/speedfan.txt', $buffer) && (strlen($buffer) > 0)) { |
||
| 54 | if (preg_match("/^Temperatures:\s+(.+)$/m", $buffer, $out)) { |
||
| 55 | $this->_filecontent["temp"] = $out[1]; |
||
| 56 | } |
||
| 57 | if (preg_match("/^Fans:\s+(.+)$/m", $buffer, $out)) { |
||
| 58 | $this->_filecontent["fans"] = $out[1]; |
||
| 59 | } |
||
| 60 | if (preg_match("/^Voltages:\s+(.+)$/m", $buffer, $out)) { |
||
| 61 | $this->_filecontent["volt"] = $out[1]; |
||
| 62 | } |
||
| 63 | } |
||
| 64 | break; |
||
| 65 | default: |
||
| 66 | $this->error->addConfigError('__construct()', 'PSI_SENSOR_SPEEDFAN_ACCESS'); |
||
| 67 | break; |
||
| 68 | } |
||
| 69 | } |
||
| 70 | |||
| 139 |
You can fix this by adding a namespace to your class:
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.