| Conditions | 6 |
| Paths | 1 |
| Total Lines | 57 |
| Code Lines | 35 |
| Lines | 32 |
| Ratio | 56.14 % |
| Changes | 2 | ||
| 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 |
||
| 76 | private function extractRates(Crawler $crawler, \DateTime $date) |
||
| 77 | { |
||
| 78 | $rates = array(); |
||
| 79 | |||
| 80 | $crawler->filter('tr')->each(function (Crawler $node) use ($date, &$rates) { |
||
| 81 | |||
| 82 | $row = $this->parseRow($node); |
||
| 83 | |||
| 84 | if (null !== $row) { |
||
| 85 | |||
| 86 | $rates[] = $this->buildRate( |
||
| 87 | $row['default'] / $row['unit'], |
||
| 88 | $row['currencyCode'], |
||
| 89 | 'default', |
||
| 90 | $date |
||
| 91 | ); |
||
| 92 | |||
| 93 | View Code Duplication | if ($row['foreign_exchange_buying'] > 0) { |
|
| 94 | $rates[] = $this->buildRate( |
||
| 95 | $row['foreign_exchange_buying'] / $row['unit'], |
||
| 96 | $row['currencyCode'], |
||
| 97 | 'foreign_exchange_buying', |
||
| 98 | $date |
||
| 99 | ); |
||
| 100 | } |
||
| 101 | |||
| 102 | View Code Duplication | if ($row['foreign_exchange_selling'] > 0) { |
|
| 103 | $rates[] = $this->buildRate( |
||
| 104 | $row['foreign_exchange_selling'] / $row['unit'], |
||
| 105 | $row['currencyCode'], |
||
| 106 | 'foreign_exchange_selling', |
||
| 107 | $this->date |
||
| 108 | ); |
||
| 109 | } |
||
| 110 | |||
| 111 | View Code Duplication | if ($row['foreign_cash_buying'] > 0) { |
|
| 112 | $rates[] = $this->buildRate( |
||
| 113 | $row['foreign_cash_buying'] / $row['unit'], |
||
| 114 | $row['currencyCode'], |
||
| 115 | 'foreign_cash_buying', |
||
| 116 | $this->date |
||
| 117 | ); |
||
| 118 | } |
||
| 119 | |||
| 120 | View Code Duplication | if ($row['foreign_cash_selling'] > 0) { |
|
| 121 | $rates[] = $this->buildRate( |
||
| 122 | $row['foreign_cash_selling'] / $row['unit'], |
||
| 123 | $row['currencyCode'], |
||
| 124 | 'foreign_cash_selling', |
||
| 125 | $this->date |
||
| 126 | ); |
||
| 127 | } |
||
| 128 | } |
||
| 129 | }); |
||
| 130 | |||
| 131 | return $rates; |
||
| 132 | } |
||
| 133 | |||
| 184 |
This check marks private properties in classes that are never used. Those properties can be removed.