| Conditions | 1 |
| Paths | 1 |
| Total Lines | 52 |
| Code Lines | 38 |
| 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 |
||
| 33 | protected function setUp() |
||
| 34 | { |
||
| 35 | parent::setUp(); |
||
| 36 | |||
| 37 | static::bootKernel(['environment' => 'test_container_creation']); |
||
| 38 | |||
| 39 | /** @var Client $client */ |
||
| 40 | $this->client = static::createClient(); |
||
| 41 | /** @var Manager $manager */ |
||
| 42 | $manager = static::$kernel->getContainer()->get('es.manager'); |
||
| 43 | |||
| 44 | // There is something wrong with ElasticsearchTestCase method getDataArray, |
||
| 45 | // if we don't create in here all test data, it's not existing when test is run. |
||
| 46 | $content = new Profile(); |
||
| 47 | $content->setId('default_profile'); |
||
| 48 | $content->setName('default'); |
||
| 49 | $manager->persist($content); |
||
| 50 | |||
| 51 | $content = new Profile(); |
||
| 52 | $content->setName('profile_foo.com_profile'); |
||
| 53 | $content->setName('profile_foo.com'); |
||
| 54 | $manager->persist($content); |
||
| 55 | |||
| 56 | $content = new Setting(); |
||
| 57 | $content->setId('foo_default'); |
||
| 58 | $content->setName('test'); |
||
| 59 | $content->setProfile('default'); |
||
| 60 | $content->setDescription('Description'); |
||
| 61 | $content->setType(Setting::TYPE_ARRAY); |
||
| 62 | $content->setData((object)['value' => 'testData']); |
||
| 63 | $manager->persist($content); |
||
| 64 | |||
| 65 | $content = new Setting(); |
||
| 66 | $content->setId('foo'); |
||
| 67 | $content->setName('test2'); |
||
| 68 | $content->setProfile('profile_foo.com'); |
||
| 69 | $content->setDescription('Description'); |
||
| 70 | $content->setType(Setting::TYPE_ARRAY); |
||
| 71 | $content->setData((object)['value' => 'testData']); |
||
| 72 | $manager->persist($content); |
||
| 73 | |||
| 74 | $content = new Setting(); |
||
| 75 | $content->setId('bar'); |
||
| 76 | $content->setName('test2'); |
||
| 77 | $content->setProfile('profile_foo.com'); |
||
| 78 | $content->setDescription('Description'); |
||
| 79 | $content->setType(Setting::TYPE_ARRAY); |
||
| 80 | $content->setData((object)['value' => 'testData']); |
||
| 81 | $manager->persist($content); |
||
| 82 | |||
| 83 | $manager->commit(); |
||
| 84 | } |
||
| 85 | |||
| 125 |