Completed
Branch master (030db8)
by Kirill
02:25
created

LoadVariableData::load()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 56
Code Lines 37

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 38
CRAP Score 1

Importance

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