| Conditions | 7 |
| Paths | 7 |
| Total Lines | 62 |
| Code Lines | 49 |
| Lines | 14 |
| Ratio | 22.58 % |
| Changes | 5 | ||
| Bugs | 3 | 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 |
||
| 43 | $files = get_included_files(); |
||
| 44 | $fileList = array(); |
||
| 45 | $fileTotals = array( |
||
| 46 | "count" => count($files), |
||
| 47 | "size" => 0, |
||
| 48 | "largest" => 0, |
||
| 49 | ); |
||
| 50 | |||
| 51 | foreach($files as $file) { |
||
| 52 | $size = filesize($file); |
||
| 53 | $fileList[] = array( |
||
| 54 | 'name' => $file, |
||
| 55 | 'size' => $this->getReadableFileSize($size) |
||
| 56 | ); |
||
| 57 | $fileTotals['size'] += $size; |
||
| 58 | if($size > $fileTotals['largest']) $fileTotals['largest'] = $size; |
||
| 59 | } |
||
| 60 | |||
| 61 | $fileTotals['size'] = $this->getReadableFileSize($fileTotals['size']); |
||
| 62 | $fileTotals['largest'] = $this->getReadableFileSize($fileTotals['largest']); |
||
| 63 | |||
| 64 | return array( |
||
| 65 | 'files' => $fileList, |
||
| 66 | 'fileTotals' => $fileTotals |
||
| 67 | ); |
||
| 68 | } |
||
| 69 | |||
| 70 | /** |
||
| 71 | * Get data about memory usage of the application |
||
| 72 | * |
||
| 73 | * @returns array |
||
| 74 | */ |
||
| 75 | public function gatherMemoryData() |
||
| 76 | { |
||
| 77 | $usedMemory = memory_get_peak_usage(); |
||
| 78 | $allowedMemory = ini_get('memory_limit'); |
||
| 79 | return array( |
||
| 80 | 'used' => $usedMemory, |
||
| 81 | 'allowed' => $allowedMemory |
||
| 82 | ); |
||
| 83 | } |
||
| 84 | |||
| 85 | /*-------------------------------------------------------- |
||
| 86 | QUERY DATA -- DATABASE OBJECT WITH LOGGING REQUIRED |
||
| 87 | ----------------------------------------------------------*/ |
||
| 88 | |||
| 89 | public function gatherQueryData() { |
||
| 90 | $queryTotals = array(); |
||
| 91 | $queryTotals['count'] = 0; |
||
| 92 | $queryTotals['time'] = 0; |
||
| 93 | $queries = array(); |
||
| 94 | |||
| 95 | if($this->db != '') { |
||
| 96 | $queryTotals['count'] += $this->db->queryCount; |
||
| 97 | foreach($this->db->queries as $query) { |
||
| 98 | $query = $this->attemptToExplainQuery($query); |
||
| 99 | $queryTotals['time'] += $query['time']; |
||
| 100 | $query['time'] = $this->getReadableTime($query['time']); |
||
| 101 | $queries[] = $query; |
||
| 102 | } |
||
| 103 | } |
||
| 104 | |||
| 105 | $queryTotals['time'] = $this->getReadableTime($queryTotals['time']); |
||
| 202 |
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..