Conditions | 11 |
Paths | 1024 |
Total Lines | 53 |
Code Lines | 32 |
Lines | 0 |
Ratio | 0 % |
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 |
||
83 | public function makeInvoice($invoiceData = []) |
||
84 | { |
||
85 | if (!isset($invoiceData['kod'])) { |
||
86 | $invoiceData['kod'] = 'PeeHP'.time(); |
||
87 | } |
||
88 | if (!isset($invoiceData['varSym'])) { |
||
89 | $invoiceData['varSym'] = \Ease\Sand::randomNumber(1000, 99999); |
||
90 | } |
||
91 | if (!isset($invoiceData['datVyst'])) { |
||
92 | $invoiceData['datVyst'] = date("Y-m-d", time() - 60 * 60 * 24); |
||
93 | } |
||
94 | if (!isset($invoiceData['typDokl'])) { |
||
95 | $invoiceData['typDokl'] = 'code:FAKTURA'; |
||
96 | } |
||
97 | if (!isset($invoiceData['zdrojProSkl'])) { |
||
98 | $invoiceData['zdrojProSkl'] = false; |
||
99 | } |
||
100 | if (!isset($invoiceData['dobropisovano'])) { |
||
101 | $invoiceData['dobropisovano'] = false; |
||
102 | } |
||
103 | |||
104 | if (!isset($invoiceData['polozky'])) { |
||
105 | $invoiceData['bezPolozek'] = true; |
||
106 | } |
||
107 | |||
108 | if (!isset($invoiceData['sumCelkZakl'])) { |
||
109 | $scale = pow(1000, 2); |
||
110 | $invoiceData['sumCelkZakl'] = round(mt_rand(10 * $scale, |
||
111 | 9000 * $scale) / $scale, 2); |
||
112 | } |
||
113 | |||
114 | if (!isset($invoiceData['firma'])) { |
||
115 | $adresar = new \FlexiPeeHP\Adresar(); |
||
116 | |||
117 | $adresy = $adresar->getFlexiData(null, |
||
118 | ['typVztahuK' => 'typVztahu.odberatel']); |
||
119 | |||
120 | $dodavatel = $adresy[array_rand($adresy)]; |
||
121 | |||
122 | $invoiceData['firma'] = 'code:'.$dodavatel['kod']; |
||
123 | } |
||
124 | |||
125 | if (!isset($ivoiceData['poznam'])) { |
||
|
|||
126 | $invoiceData['poznam'] = $this->poznam; |
||
127 | } |
||
128 | |||
129 | $this->object->takeData($invoiceData); |
||
130 | $result = $this->object->insertToFlexiBee(); |
||
131 | |||
132 | $id = $this->object->getLastInsertedId(); |
||
133 | $this->object->setDataValue('id', $id); |
||
134 | return $id; |
||
135 | } |
||
136 | } |
This check looks for variables that are accessed but have not been defined. It raises an issue if it finds another variable that has a similar name.
The variable may have been renamed without also renaming all references.