PhotoFixtures   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 41
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 27
c 1
b 0
f 0
dl 0
loc 41
rs 10
wmc 4

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getPhotoData() 0 20 1
A getDependencies() 0 4 1
A load() 0 10 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace App\DataFixtures;
6
7
use App\Entity\Photo;
8
use Doctrine\Bundle\FixturesBundle\Fixture;
9
use Doctrine\Common\DataFixtures\DependentFixtureInterface;
10
use Doctrine\Persistence\ObjectManager;
11
12
final class PhotoFixtures extends Fixture implements DependentFixtureInterface
13
{
14
    public function load(ObjectManager $manager): void
15
    {
16
        foreach ($this->getPhotoData() as [$property, $priority, $file]) {
17
            $photo = new Photo();
18
            $photo->setProperty($property);
19
            $photo->setSortOrder($priority);
20
            $photo->setPhoto($file);
21
            $manager->persist($photo);
22
        }
23
        $manager->flush();
24
    }
25
26
    private function getPhotoData(): array
27
    {
28
        return [
29
            // $photoData = [$property, $priority, $file];
30
            [$this->getReference('bright-and-cheerful-alcove-studio'), 1, 'demo/1.jpeg'],
31
            [$this->getReference('bright-and-cheerful-alcove-studio'), 2, 'demo/2.jpeg'],
32
            [$this->getReference('modern-one-bedroom-apartment-in-miami'), 1, 'demo/3.jpeg'],
33
            [$this->getReference('modern-one-bedroom-apartment-in-miami'), 2, 'demo/4.jpeg'],
34
            [$this->getReference('stylish-two-level-penthouse-in-palm-beach'), 1, 'demo/5.jpeg'],
35
            [$this->getReference('stylish-two-level-penthouse-in-palm-beach'), 2, 'demo/6.jpeg'],
36
            [$this->getReference('bright-fully-furnished-1-bedroom-flat-on-the-2nd-floor'), 1, 'demo/7.jpeg'],
37
            [$this->getReference('bright-fully-furnished-1-bedroom-flat-on-the-2nd-floor'), 2, 'demo/2.jpeg'],
38
            [$this->getReference('beautiful-villa-for-sale-in-tampa'), 1, 'demo/8.jpeg'],
39
            [$this->getReference('beautiful-villa-for-sale-in-tampa'), 2, 'demo/9.jpeg'],
40
            [$this->getReference('beautiful-villa-for-sale-in-tampa'), 3, 'demo/4.jpeg'],
41
            [$this->getReference('furnished-renovated-2-bedroom-2-bathroom-flat'), 1, 'demo/10.jpeg'],
42
            [$this->getReference('furnished-renovated-2-bedroom-2-bathroom-flat'), 2, 'demo/6.jpeg'],
43
            [$this->getReference('interesting-two-bedroom-apartment-for-sale'), 1, 'demo/11.jpeg'],
44
            [$this->getReference('interesting-two-bedroom-apartment-for-sale'), 2, 'demo/12.jpeg'],
45
            [$this->getReference('interesting-two-bedroom-apartment-for-sale'), 3, 'demo/13.jpeg'],
46
        ];
47
    }
48
49
    public function getDependencies()
50
    {
51
        return [
52
            PropertyFixtures::class,
53
        ];
54
    }
55
}
56