Passed
Push — master ( 62083f...ad8d4a )
by Julito
10:31
created

BranchFixtures   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 9
dl 0
loc 19
rs 10
c 1
b 0
f 0
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A load() 0 17 1
1
<?php
2
3
declare(strict_types=1);
4
5
/* For licensing terms, see /license.txt */
6
7
namespace Chamilo\CoreBundle\DataFixtures;
8
9
use Chamilo\CoreBundle\Entity\BranchSync;
10
use Doctrine\Bundle\FixturesBundle\Fixture;
11
use Doctrine\Persistence\ObjectManager;
12
use Symfony\Component\Uid\Uuid;
13
14
class BranchFixtures extends Fixture
15
{
16
    public function load(ObjectManager $manager): void
17
    {
18
        // Original query in data.sql
19
        // INSERT INTO branch_sync (access_url_id, branch_name, unique_id, ssl_pub_key)
20
        // VALUES (1, 'localhost', SHA1(UUID()), SHA1(UUID()));
21
22
        $url = $this->getReference(AccessUrlAdminFixtures::ACCESS_URL_REFERENCE);
23
24
        $branch = (new BranchSync())
25
            ->setBranchName('localhost')
26
            ->setUniqueId(sha1(Uuid::v1()->toRfc4122()))
27
            ->setSslPubKey(sha1(Uuid::v1()->toRfc4122()))
28
            ->setUrl($url)
29
        ;
30
31
        $manager->persist($branch);
32
        $manager->flush();
33
    }
34
}
35