MenuFixtures   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 17
c 1
b 0
f 0
dl 0
loc 25
rs 10
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A load() 0 11 2
A getMenuData() 0 10 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace App\DataFixtures;
6
7
use App\Entity\Menu;
8
use Doctrine\Bundle\FixturesBundle\Fixture;
9
use Doctrine\Persistence\ObjectManager;
10
11
final class MenuFixtures extends Fixture
12
{
13
    public function load(ObjectManager $manager): void
14
    {
15
        foreach ($this->getMenuData() as [$title, $url, $locale]) {
16
            $menu = new Menu();
17
            $menu->setTitle($title);
18
            $menu->setUrl($url);
19
            $menu->setLocale($locale);
20
            $manager->persist($menu);
21
            $this->addReference($title, $menu);
22
        }
23
        $manager->flush();
24
    }
25
26
    private function getMenuData(): array
27
    {
28
        return [
29
            ['Homepage', '/', 'en'],
30
            ['About Us', '/info/about-us', 'en'],
31
            ['Contact', '/info/contact', 'en'],
32
            ['Начало', '/', 'bg'],
33
            ['За нас', '/info/about-us', 'bg'],
34
            ['Контакти', '/info/contact', 'bg'],
35
            ['Source Code', 'https://github.com/Coderberg/ResidenceCMS', 'en'],
36
        ];
37
    }
38
}
39