Completed
Push — master ( b4d909...e3c084 )
by Valentyn
03:37
created

ActorsFixtures::load()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 10

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 10
ccs 0
cts 8
cp 0
rs 9.9332
c 0
b 0
f 0
cc 1
nc 1
nop 1
crap 2
1
<?php
2
3
namespace App\Actors\DataFixtures;
4
5
use App\Actors\Entity\Actor;
6
use App\Actors\Entity\ActorTMDB;
7
use App\Actors\Entity\ActorTranslations;
8
use Doctrine\Bundle\FixturesBundle\Fixture;
9
use Doctrine\Common\Persistence\ObjectManager;
10
11
class ActorsFixtures extends Fixture
12
{
13
    const ACTOR_ORIGINAL_NAME = 'Original Name';
14
    const ACTOR_TMDB_ID = 1;
15
16
    /**
17
     * @param ObjectManager $manager
18
     *
19
     * @throws \Exception
20
     */
21
    public function load(ObjectManager $manager): void
22
    {
23
        $actorTmdb = new ActorTMDB(self::ACTOR_TMDB_ID);
24
        $actor = new Actor(self::ACTOR_ORIGINAL_NAME, $actorTmdb);
25
        $actor->addTranslation(new ActorTranslations($actor, 'en', self::ACTOR_ORIGINAL_NAME));
26
        $actor->addTranslation(new ActorTranslations($actor, 'pl', 'Name'));
27
28
        $manager->persist($actor);
29
        $manager->flush();
30
    }
31
}
32