Conditions | 16 |
Paths | 720 |
Total Lines | 100 |
Code Lines | 63 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
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 |
||
56 | public function up() |
||
57 | { |
||
58 | // Migrate estimate/invoice numbers to new ref field |
||
59 | $this->log('- Migrating estimate/invoice numbers'); |
||
60 | $total = 0; |
||
61 | |||
62 | if (class_exists(Subsite::class)) { |
||
63 | $items = Subsite::get_from_all_subsites(Estimate::class); |
||
64 | } else { |
||
65 | $items = Estimate::get(); |
||
66 | } |
||
67 | |||
68 | $count = false; |
||
69 | if ($items) { |
||
70 | $this->log('- '.$items->count().' items to convert.'); |
||
71 | $count = $items->count(); |
||
72 | } |
||
73 | $i = 0; |
||
74 | |||
75 | foreach ($items as $item) { |
||
76 | if ($item->Number !== null) { |
||
77 | $config = SiteConfig::current_site_config(); |
||
78 | $inv_prefix = $config->InvoiceNumberPrefix; |
||
79 | $est_prefix = $config->EstimateNumberPrefix; |
||
80 | $number = $item->Number; |
||
81 | |||
82 | // Strip off current prefix and convert to a ref |
||
83 | if ($item instanceof Invoice) { |
||
84 | $ref = str_replace($inv_prefix . "-", "", $number); |
||
85 | $ref = str_replace('-', '', $ref); |
||
86 | $item->Ref = (int)$ref; |
||
87 | $item->Prefix = $inv_prefix; |
||
88 | } else { |
||
89 | $ref = str_replace($est_prefix . "-", "", $number); |
||
90 | $ref = str_replace('-', '', $ref); |
||
91 | $item->Ref = (int)$ref; |
||
92 | $item->Prefix = $est_prefix; |
||
93 | } |
||
94 | |||
95 | $item->Number = null; |
||
96 | $item->write(); |
||
97 | } |
||
98 | $i++; |
||
99 | $this->log('- '.$i.'/'.$count.' items migrated.', true); |
||
100 | } |
||
101 | |||
102 | unset($items); |
||
103 | |||
104 | // Change price/tax on line items to use new fields from extension |
||
105 | $items = LineItem::get(); |
||
106 | $count = $items->count(); |
||
107 | $this->log("Migrating {$count} Line Items"); |
||
108 | $i = 0; |
||
109 | |||
110 | foreach ($items as $item) { |
||
111 | $write = false; |
||
112 | |||
113 | if ((int)$item->Price && (int)$item->BasePrice == 0) { |
||
114 | $item->BasePrice = $item->Price; |
||
115 | $write = true; |
||
116 | } |
||
117 | |||
118 | if ($item->TaxID != 0 && $item->TaxRateID == 0) { |
||
119 | $item->TaxRateID = $item->TaxID; |
||
120 | $write = true; |
||
121 | } |
||
122 | |||
123 | if ($write) { |
||
124 | $item->write(); |
||
125 | $i++; |
||
126 | } |
||
127 | } |
||
128 | |||
129 | unset($items); |
||
130 | |||
131 | $this->log("Migrated {$i} Line Item Customisations"); |
||
132 | |||
133 | // Change price/tax on line items to use new fields from extension |
||
134 | $items = LineItemCustomisation::get(); |
||
135 | $count = $items->count(); |
||
136 | $this->log("Migrating {$count} Line Items"); |
||
137 | $i = 0; |
||
138 | |||
139 | foreach ($items as $item) { |
||
140 | $write = false; |
||
141 | |||
142 | if ((int)$item->Price && (int)$item->BasePrice == 0) { |
||
143 | $item->BasePrice = $item->Price; |
||
144 | $write = true; |
||
145 | } |
||
146 | |||
147 | if ($write) { |
||
148 | $item->write(); |
||
149 | $i++; |
||
150 | } |
||
151 | } |
||
152 | |||
153 | unset($items); |
||
154 | |||
155 | $this->log("Migrated {$i} Line Items"); |
||
156 | } |
||
182 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths