LoadVariableData::load()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 63
Code Lines 41

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 42
CRAP Score 1

Importance

Changes 2
Bugs 1 Features 0
Metric Value
dl 0
loc 63
ccs 42
cts 42
cp 1
rs 9.4347
c 2
b 1
f 0
cc 1
eloc 41
nc 1
nop 1
crap 1

How to fix   Long Method   

Long Method

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:

1
<?php
2
3
namespace AppBundle\DataFixtures\ORM;
4
5
use Doctrine\Common\DataFixtures\FixtureInterface;
6
use Doctrine\Common\Persistence\ObjectManager;
7
use AppBundle\Entity\Variable;
8
9
class LoadVariableData implements FixtureInterface
10
{
11 6
    public function load(ObjectManager $manager)
12
    {
13 6
        $variable = new Variable();
14
15 6
        $variable->setName('temperature');
16 6
        $variable->setDescription('test temperature metric');
17 6
        $variable->setSource('internal');
18 6
        $variable->setParser('Simple');
19 6
        $variable->setValue('20');
20
21 6
        $variable->needHistory = true;
22
23 6
        $manager->persist($variable);
24
25
26 6
        $variable = new Variable();
27
28 6
        $variable->setName('humidity');
29 6
        $variable->setDescription('test humidity metric');
30 6
        $variable->setSource('internal');
31 6
        $variable->setParser('Argument');
32 6
        $variable->setValue('70');
33
34 6
        $variable->needHistory = true;
35
36 6
        $manager->persist($variable);
37
38 6
        $variable = new Variable();
39
40 6
        $variable->setName('internet.upload');
41 6
        $variable->setDescription('test humidity metric');
42 6
        $variable->setSource('internal');
43 6
        $variable->setParser('Argument');
44 6
        $variable->setValue('70');
45
46 6
        $manager->persist($variable);
47
48 6
        $variable = new Variable();
49
50 6
        $variable->setName('internet.download');
51 6
        $variable->setDescription('test humidity metric');
52 6
        $variable->setSource('internal');
53 6
        $variable->setParser('Argument');
54 6
        $variable->setValue('70');
55
56 6
        $variable->needHistory = true;
57
58 6
        $manager->persist($variable);
59
60 6
        $variable = new Variable();
61
62 6
        $variable->setName('internet.ping');
63 6
        $variable->setDescription('test humidity metric');
64 6
        $variable->setSource('internal');
65 6
        $variable->setParser('Argument');
66 6
        $variable->setValue('70');
67 6
        $variable->needHistory = true;
68
69 6
        $manager->persist($variable);
70
71
72 6
        $manager->flush();
73 6
    }
74
}
75