Completed
Push — master ( a9d3b9...e09e3d )
by Kirill
03:27
created

LoadVariableData::load()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 63
Code Lines 41

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

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

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
    public function load(ObjectManager $manager)
12
    {
13
        $variable = new Variable();
14
15
        $variable->setName('temperature');
16
        $variable->setDescription('test temperature metric');
17
        $variable->setSource('internal');
18
        $variable->setParser('Simple');
19
        $variable->setValue('20');
20
21
        $variable->needHistory = true;
22
23
        $manager->persist($variable);
24
25
26
        $variable = new Variable();
27
28
        $variable->setName('humidity');
29
        $variable->setDescription('test humidity metric');
30
        $variable->setSource('internal');
31
        $variable->setParser('Argument');
32
        $variable->setValue('70');
33
34
        $variable->needHistory = true;
35
36
        $manager->persist($variable);
37
38
        $variable = new Variable();
39
40
        $variable->setName('internet.upload');
41
        $variable->setDescription('test humidity metric');
42
        $variable->setSource('internal');
43
        $variable->setParser('Argument');
44
        $variable->setValue('70');
45
46
        $manager->persist($variable);
47
48
        $variable = new Variable();
49
50
        $variable->setName('internet.download');
51
        $variable->setDescription('test humidity metric');
52
        $variable->setSource('internal');
53
        $variable->setParser('Argument');
54
        $variable->setValue('70');
55
56
        $variable->needHistory = true;
57
58
        $manager->persist($variable);
59
60
        $variable = new Variable();
61
62
        $variable->setName('internet.ping');
63
        $variable->setDescription('test humidity metric');
64
        $variable->setSource('internal');
65
        $variable->setParser('Argument');
66
        $variable->setValue('70');
67
        $variable->needHistory = true;
68
69
        $manager->persist($variable);
70
71
72
        $manager->flush();
73
    }
74
}
75