Completed
Push — master ( c5110b...a167e6 )
by Valentyn
13:46
created

CountriesFixtures   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 5

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 5
dl 0
loc 28
ccs 0
cts 14
cp 0
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A load() 0 20 2
1
<?php
2
3
namespace App\Countries\DataFixtures;
4
5
use App\Countries\Entity\Country;
6
use App\Countries\Entity\ImdbCountry;
7
use Doctrine\Bundle\FixturesBundle\Fixture;
8
use Doctrine\Common\Persistence\ObjectManager;
9
use Doctrine\ORM\EntityManager;
10
11
class CountriesFixtures extends Fixture
12
{
13
    const COUNTRY_UKR_ID = 1;
14
    const COUNTRY_UKR_CODE = 'UKR';
15
    const COUNTRY_POL_ID = 2;
16
    const COUNTRY_POL_CODE = 'POL';
17
18
    public function load(ObjectManager $manager): void
19
    {
20
        if ($manager instanceof EntityManager === false) {
21
            throw new \InvalidArgumentException('UsersFixtures $manager should be instance of EntityManager');
22
        }
23
        /* @var $manager EntityManager */
24
25
        $ukr = new Country('Ukraine', 'UKR');
26
        $pol = new Country('Poland', 'POL');
27
        $imdbUkr = new ImdbCountry($ukr);
28
        $imdbPol = new ImdbCountry($pol);
29
30
        $manager->getConnection()->exec("ALTER SEQUENCE countries_id_seq RESTART WITH 1; UPDATE countries SET id=nextval('countries_id_seq');");
31
32
        $manager->persist($ukr);
33
        $manager->persist($pol);
34
        $manager->persist($imdbUkr);
35
        $manager->persist($imdbPol);
36
        $manager->flush();
37
    }
38
}
39