RoleFixtures   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 16
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 10
dl 0
loc 16
rs 10
c 0
b 0
f 0
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A load() 0 8 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Gbere\SimpleAuth\DataFixtures;
6
7
use Doctrine\Bundle\FixturesBundle\Fixture;
8
use Doctrine\Persistence\ObjectManager;
9
use Gbere\SimpleAuth\Entity\Role;
10
11
class RoleFixtures extends Fixture
12
{
13
    /** @var array */
14
    private const ROLES = [
15
        'ROLE_USER' => 'role_user.description',
16
        'ROLE_ADMIN' => 'role_admin.description',
17
    ];
18
19
    public function load(ObjectManager $manager): void
20
    {
21
        foreach (self::ROLES as $roleName => $roleDescription) {
22
            $role = new Role();
23
            $role->setName($roleName);
24
            $role->setDescription($roleDescription);
25
            $manager->persist($role);
26
            $manager->flush();
27
        }
28
    }
29
}
30