Conditions | 2 |
Paths | 13 |
Total Lines | 66 |
Code Lines | 51 |
Lines | 0 |
Ratio | 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 |
||
15 | public function actionIndex() |
||
16 | { |
||
17 | try |
||
18 | { |
||
19 | $productWriter = new ImportProductWriter($this->logger); |
||
20 | $productWriter->clear = true; |
||
21 | $productWriter->clearTables = array( |
||
22 | '{{product}}', |
||
23 | '{{product_assignment}}', |
||
24 | '{{product_param}}', |
||
25 | '{{product_param_variant}}', |
||
26 | '{{product_tree_assignment}}', |
||
27 | '{{product_section}}', |
||
28 | '{{product_type}}', |
||
29 | '{{product_category}}', |
||
30 | '{{product_collection}}', |
||
31 | '{{product_param_name}}', |
||
32 | ); |
||
33 | $productWriter->uniqueAttribute = 'external_id'; |
||
34 | $productWriter->assignmentTree = array('type_id' => 'section_id', 'collection_id' => 'type_id'); |
||
35 | $productWriter->assignment = array('section_id', 'type_id', 'collection_id', 'category_id'); |
||
36 | |||
37 | $productAggregator = new ProductAggregator($productWriter); |
||
38 | |||
39 | $productAggregator->assignmentDelimiter = '@'; |
||
40 | $productAggregator->parameterVariantsDelimiter = '@'; |
||
41 | $productAggregator->collectItemBufferSize = null; |
||
42 | |||
43 | $productAggregator->groupByColumn = ImportHelper::lettersToNumber('f'); |
||
44 | $productAggregator->product = ImportHelper::convertColumnIndexes(array( |
||
|
|||
45 | 'name' => 'g', |
||
46 | 'articul' => 'i', |
||
47 | 'price' => 'k', |
||
48 | 'url' => 'w', |
||
49 | 'notice' => 'q', |
||
50 | 'content' => 'r', |
||
51 | 'visible' => 't', |
||
52 | 'dump' => 'l', |
||
53 | 'external_id' => 'p', |
||
54 | 'model' => 'f' |
||
55 | )); |
||
56 | $productAggregator->basketParameter = array(ImportHelper::lettersToNumber('h')); |
||
57 | $productAggregator->assignment = ImportHelper::convertColumnIndexes(array( |
||
58 | 'section_id' => 'b', |
||
59 | 'type_id' => 'c', |
||
60 | 'collection_id' => 'd', |
||
61 | 'category_id' => 'e', |
||
62 | )); |
||
63 | $productAggregator->parameter = ImportHelper::convertColumnIndexes(ImportHelper::getLettersRange('z-en')); |
||
64 | $productAggregator->parameterCommon = ImportHelper::convertColumnIndexes(ImportHelper::getLettersRange('z-ac')); |
||
65 | |||
66 | $csvReader = new ImportCsvReader($this->logger, $productAggregator); |
||
67 | $csvReader->csvDelimiter = ','; |
||
68 | $csvReader->headerRowIndex = 2; |
||
69 | $csvReader->skipTopRowAmount = 2; |
||
70 | $csvReader->start(); |
||
71 | $csvReader->processFiles(ImportHelper::getFiles('f/prices')); |
||
72 | $csvReader->finish(); |
||
73 | |||
74 | //$this->reindex(); |
||
75 | } |
||
76 | catch(Exception $e) |
||
77 | { |
||
78 | $this->logger->error($e->getMessage()); |
||
79 | } |
||
80 | } |
||
81 | |||
95 | } |
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..