| Conditions | 2 |
| Paths | 2 |
| Total Lines | 54 |
| Code Lines | 34 |
| Lines | 0 |
| Ratio | 0 % |
| 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 | public function load(array $options) |
||
| 91 | { |
||
| 92 | $options = $this->optionsResolver->resolve($options); |
||
| 93 | |||
| 94 | $this->taxonFixture->load(['custom' => [[ |
||
| 95 | 'code' => 'category', |
||
| 96 | 'name' => 'Category', |
||
| 97 | 'children' => [ |
||
| 98 | [ |
||
| 99 | 'code' => 'stickers', |
||
| 100 | 'name' => 'Stickers', |
||
| 101 | ] |
||
| 102 | ] |
||
| 103 | ]]]); |
||
| 104 | |||
| 105 | $this->productAttributeFixture->load(['custom' => [ |
||
| 106 | ['name' => 'Sticker paper', 'code' => 'sticker_paper', 'type' => TextAttributeType::TYPE], |
||
| 107 | ['name' => 'Sticker resolution', 'code' => 'sticker_resolution', 'type' => TextAttributeType::TYPE], |
||
| 108 | ]]); |
||
| 109 | |||
| 110 | $this->productOptionFixture->load(['custom' => [ |
||
| 111 | [ |
||
| 112 | 'name' => 'Sticker size', |
||
| 113 | 'code' => 'sticker_size', |
||
| 114 | 'values' => [ |
||
| 115 | 'sticker_size-3' => '3"', |
||
| 116 | 'sticker_size_5' => '5"', |
||
| 117 | 'sticker_size_7' => '7"', |
||
| 118 | ], |
||
| 119 | ], |
||
| 120 | ]]); |
||
| 121 | |||
| 122 | $products = []; |
||
| 123 | $productsNames = $this->getUniqueNames($options['amount']); |
||
| 124 | for ($i = 0; $i < $options['amount']; ++$i) { |
||
| 125 | $products[] = [ |
||
| 126 | 'name' => sprintf('Sticker "%s"', $productsNames[$i]), |
||
| 127 | 'code' => $this->faker->uuid, |
||
| 128 | 'main_taxon' => 'stickers', |
||
| 129 | 'taxons' => ['stickers'], |
||
| 130 | 'product_attributes' => [ |
||
| 131 | 'sticker_paper' => sprintf('Paper from tree %s', $this->faker->randomElement(['Wung', 'Tanajno', 'Lemon-San', 'Me-Gusta'])), |
||
| 132 | 'sticker_resolution' => $this->faker->randomElement(['JKM XD', '476DPI', 'FULL HD', '200DPI']), |
||
| 133 | ], |
||
| 134 | 'product_options' => ['sticker_size'], |
||
| 135 | 'images' => [ |
||
| 136 | 'main' => sprintf('%s/../Resources/fixtures/%s', __DIR__, 'stickers.jpg'), |
||
| 137 | 'thumbnail' => sprintf('%s/../Resources/fixtures/%s', __DIR__, 'stickers.jpg'), |
||
| 138 | ], |
||
| 139 | ]; |
||
| 140 | } |
||
| 141 | |||
| 142 | $this->productFixture->load(['custom' => $products]); |
||
| 143 | } |
||
| 144 | |||
| 176 |
Very long variable names usually make code harder to read. It is therefore recommended not to make variable names too verbose.