Completed
Push — master ( bd2e94...030db8 )
by Kirill
07:18
created

LoadVariableData::load()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 56
Code Lines 37

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 17
CRAP Score 1

Importance

Changes 2
Bugs 1 Features 0
Metric Value
c 2
b 1
f 0
dl 0
loc 56
ccs 17
cts 17
cp 1
rs 9.7251
cc 1
eloc 37
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 3
    public function load(ObjectManager $manager)
12
    {
13 3
        $variable = new Variable();
14
15 3
        $variable->setName('temperature');
16 3
        $variable->setDescription('test temperature metric');
17 3
        $variable->setSource('internal');
18 3
        $variable->setParser('Simple');
19 3
        $variable->setValue('20');
20
21 3
        $manager->persist($variable);
22
23
24 3
        $variable = new Variable();
25
26 3
        $variable->setName('humidity');
27 3
        $variable->setDescription('test humidity metric');
28 3
        $variable->setSource('internal');
29 3
        $variable->setParser('Argument');
30 3
        $variable->setValue('70');
31
32 3
        $manager->persist($variable);
33
34
        $variable = new Variable();
35 3
36 3
        $variable->setName('internet.upload');
37
        $variable->setDescription('test humidity metric');
38
        $variable->setSource('internal');
39
        $variable->setParser('Argument');
40
        $variable->setValue('70');
41
42
        $manager->persist($variable);
43
44
        $variable = new Variable();
45
46
        $variable->setName('internet.download');
47
        $variable->setDescription('test humidity metric');
48
        $variable->setSource('internal');
49
        $variable->setParser('Argument');
50
        $variable->setValue('70');
51
52
        $manager->persist($variable);
53
54
        $variable = new Variable();
55
56
        $variable->setName('internet.ping');
57
        $variable->setDescription('test humidity metric');
58
        $variable->setSource('internal');
59
        $variable->setParser('Argument');
60
        $variable->setValue('70');
61
62
        $manager->persist($variable);
63
64
65
        $manager->flush();
66
    }
67
}
68