TestFixture   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 5

Importance

Changes 0
Metric Value
wmc 4
lcom 0
cbo 5
dl 0
loc 34
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A load() 0 23 4
1
<?php
2
3
namespace DoctrineORMModuleTest\Assets\Fixture;
4
5
use Doctrine\Common\DataFixtures\AbstractFixture;
6
use Doctrine\Common\Persistence\ObjectManager;
7
8
use DoctrineORMModuleTest\Assets\Entity\Test as TestEntity;
9
use DoctrineORMModuleTest\Assets\Entity\Category;
10
use DoctrineORMModuleTest\Assets\Entity\Country;
11
12
/**
13
 * Fixture that loads a constant amount of \DoctrineORMModuleTest\Assets\Entity\Test objects into the manager
14
 */
15
class TestFixture extends AbstractFixture
16
{
17
    /**
18
     * Number of instances to build when the fixture is loaded
19
     */
20
    const INSTANCES_COUNT = 100;
21
22
    /**
23
     * {@inheritDoc}
24
     */
25
    public function load(ObjectManager $manager)
26
    {
27
        for ($i = 0; $i < self::INSTANCES_COUNT; $i += 1) {
28
            $instance = new TestEntity();
29
            $instance->setUsername('username');
30
            $instance->setPassword('password');
31
            $manager->persist($instance);
32
        }
33
34
        for ($i = 0; $i < self::INSTANCES_COUNT; $i += 1) {
35
            $instance = new Category();
36
            $instance->setName('category');
37
            $manager->persist($instance);
38
        }
39
40
        for ($i = 0; $i < self::INSTANCES_COUNT; $i += 1) {
41
            $instance = new Country();
42
            $instance->setName('country');
43
            $manager->persist($instance);
44
        }
45
46
        $manager->flush();
47
    }
48
}
49