| Conditions | 4 |
| Paths | 2 |
| Total Lines | 73 |
| Code Lines | 33 |
| Lines | 9 |
| Ratio | 12.33 % |
| 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 |
||
| 90 | function loadAmounts() |
||
| 91 | { |
||
| 92 | $saldo_total = 0; // integer med total saldo |
||
| 93 | $saldo_rubrik_a = 0; |
||
|
|
|||
| 94 | |||
| 95 | $date_from = $this->get('date_start'); |
||
| 96 | $date_to = $this->get('date_end'); |
||
| 97 | |||
| 98 | // Salgsmoms - udg�ende |
||
| 99 | $account_vat_in = $this->getAccount(1); |
||
| 100 | $account_vat_in->getSaldo('stated', $date_from, $date_to); |
||
| 101 | $this->value['account_vat_out'] = $account_vat_in; |
||
| 102 | |||
| 103 | // ganges med -1 for at f� rigtigt fortegn til udregning |
||
| 104 | $this->value['saldo_vat_out'] = $account_vat_in->get('saldo'); |
||
| 105 | $saldo_total += -1 * $this->value['saldo_vat_out']; // total |
||
| 106 | |||
| 107 | |||
| 108 | // Moms af varek�b i udlandet |
||
| 109 | // Dette bel�b er et udregnet bel�b, som udregnes under bogf�ringen |
||
| 110 | $account_vat_abroad = $this->getAccount(2); |
||
| 111 | $account_vat_abroad->getSaldo('stated', $date_from, $date_to); |
||
| 112 | $this->value['account_vat_abroad'] = $account_vat_abroad; |
||
| 113 | |||
| 114 | // ganges med -1 for at f� rigtigt fortegn til udregning |
||
| 115 | $this->value['saldo_vat_abroad'] = $account_vat_abroad->get('saldo'); |
||
| 116 | $saldo_total += -1 * $this->value['saldo_vat_abroad']; |
||
| 117 | |||
| 118 | // K�bsmoms |
||
| 119 | // K�bsmomsen inkluderer ogs� den udregnede moms af moms af varek�b i udlandet. |
||
| 120 | // Dette bel�b er lagt p� kontoen under bogf�ringen. |
||
| 121 | $account_vat_out = $this->getAccount(3); |
||
| 122 | $account_vat_out->getSaldo('stated', $date_from, $date_to); |
||
| 123 | $this->value['account_vat_in'] = $account_vat_out; |
||
| 124 | |||
| 125 | $this->value['saldo_vat_in'] = $account_vat_out->get('saldo'); |
||
| 126 | $saldo_total -= $this->value['saldo_vat_in']; |
||
| 127 | |||
| 128 | |||
| 129 | // Rubrik A |
||
| 130 | // EU-erhvervelser - her samles forskellige konti og bel�bet udregnes. |
||
| 131 | // Primosaldoen skal ikke medregnes |
||
| 132 | $buy_eu_accounts = unserialize($this->year->getSetting('buy_eu_accounts')); |
||
| 133 | $this->value['saldo_rubrik_a'] = 0; |
||
| 134 | $saldo_rubrik_a = 0; |
||
| 135 | |||
| 136 | View Code Duplication | if (is_array($buy_eu_accounts) and count($buy_eu_accounts) > 0) { |
|
| 137 | foreach ($buy_eu_accounts as $key => $id) { |
||
| 138 | $account_eu_buy = new FakeVatPeriodAccount($this->year, $id); |
||
| 139 | $primo = $account_eu_buy->getPrimoSaldo(); |
||
| 140 | $account_eu_buy->getSaldo('stated', $date_from, $date_to); |
||
| 141 | $saldo_rubrik_a += $account_eu_buy->get('saldo'); |
||
| 142 | $saldo_rubrik_a -= $primo['saldo']; |
||
| 143 | } |
||
| 144 | } |
||
| 145 | $this->value['saldo_rubrik_a'] = $saldo_rubrik_a; |
||
| 146 | |||
| 147 | // Rubrik B |
||
| 148 | // V�rdien af varesalg uden moms til andre EU-lande (EU-leverancer). Udfyldes |
||
| 149 | // denne rubrik, skal der indsendes en liste med varesalgene uden moms. |
||
| 150 | |||
| 151 | // Vi underst�tter ikke rubrikken |
||
| 152 | |||
| 153 | // Rubrik C |
||
| 154 | // V�rdien af varesalg uden moms til andre EU-lande (EU-leverancer). Udfyldes |
||
| 155 | // denne rubrik, skal der indsendes en liste med varesalgene uden moms. |
||
| 156 | |||
| 157 | // Vi underst�tter ikke rubrikken |
||
| 158 | |||
| 159 | $this->value['saldo_total'] = $saldo_total; |
||
| 160 | |||
| 161 | return true; |
||
| 162 | } |
||
| 163 | } |
||
| 226 |
This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.
Both the
$myVarassignment in line 1 and the$higherassignment in line 2 are dead. The first because$myVaris never used and the second because$higheris always overwritten for every possible time line.