Test Setup Failed
Pull Request — master (#29)
by
unknown
04:19 queued 32s
created

PropertyFixtures::getPropertyData()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 23

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 23
rs 9.552
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace App\DataFixtures;
6
7
use App\Entity\Property;
8
use App\Utils\Slugger;
9
use Doctrine\Bundle\FixturesBundle\Fixture;
10
use Doctrine\Common\DataFixtures\DependentFixtureInterface;
11
use Doctrine\Persistence\ObjectManager;
12
13
final class PropertyFixtures extends Fixture implements DependentFixtureInterface
14
{
15
    public function load(ObjectManager $manager): void
16
    {
17
        foreach ($this->getPropertyData() as [$author, $dealType, $category, $bedrooms, $guests, $city, $district,
18
                 $neighborhood, $title, $address, $latitude, $longitude, $price, $priceType, ]) {
19
            $property = new Property();
20
            $property->setAuthor($author);
0 ignored issues
show
Bug introduced by
The variable $author does not exist. Did you forget to declare it?

This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.

Loading history...
21
            $property->setDealType($dealType);
0 ignored issues
show
Bug introduced by
The variable $dealType does not exist. Did you forget to declare it?

This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.

Loading history...
22
            $property->setCategory($category);
0 ignored issues
show
Bug introduced by
The variable $category does not exist. Did you forget to declare it?

This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.

Loading history...
23
            $property->setBedroomsNumber($bedrooms);
0 ignored issues
show
Bug introduced by
The variable $bedrooms does not exist. Did you forget to declare it?

This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.

Loading history...
24
            $property->setMaxGuests($guests);
0 ignored issues
show
Bug introduced by
The variable $guests does not exist. Did you forget to declare it?

This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.

Loading history...
25
            $property->setCity($city);
0 ignored issues
show
Bug introduced by
The variable $city does not exist. Did you forget to declare it?

This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.

Loading history...
26
            $property->setNeighborhood($neighborhood);
0 ignored issues
show
Bug introduced by
The variable $neighborhood does not exist. Did you forget to declare it?

This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.

Loading history...
27
            $property->setDistrict($district);
0 ignored issues
show
Bug introduced by
The variable $district does not exist. Did you forget to declare it?

This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.

Loading history...
28
            $property->setTitle($title);
0 ignored issues
show
Bug introduced by
The variable $title does not exist. Did you forget to declare it?

This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.

Loading history...
29
            $property->setMetaDescription($title);
30
            $property->setSlug(Slugger::slugify($title));
31
            $property->setContent($this->getPropertyContent());
32
            $property->setAddress($address);
0 ignored issues
show
Bug introduced by
The variable $address does not exist. Did you forget to declare it?

This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.

Loading history...
33
            $property->setLatitude($latitude);
0 ignored issues
show
Bug introduced by
The variable $latitude does not exist. Did you forget to declare it?

This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.

Loading history...
34
            $property->setLongitude($longitude);
0 ignored issues
show
Bug introduced by
The variable $longitude does not exist. Did you forget to declare it?

This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.

Loading history...
35
            $property->setShowMap(true);
36
            $property->setPrice($price);
0 ignored issues
show
Bug introduced by
The variable $price does not exist. Did you forget to declare it?

This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.

Loading history...
37
            $property->setPriceType($priceType);
0 ignored issues
show
Bug introduced by
The variable $priceType does not exist. Did you forget to declare it?

This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.

Loading history...
38
            $property->setState('published');
39
            $property->setCreatedAt(new \DateTime('now'));
40
            $property->setUpdatedAt(new \DateTime('now'));
41
            $property->addFeature($this->getReference('Климатизация'));
42
            $property->addFeature($this->getReference('Балкон'));
43
            $property->addFeature($this->getReference('Противопожарна аларма'));
44
            $property->addFeature($this->getReference('Интериорни врати'));
45
            $property->addFeature($this->getReference('Защитен паркинг'));
46
            $property->setPriorityNumber(0);
47
            $manager->persist($property);
48
            $this->addReference(Slugger::slugify($title), $property);
49
        }
50
        $manager->flush();
51
    }
52
53
    private function getPropertyData(): array
54
    {
55
        return [
56
            /*
57
                $propertyData = [$author, $dealType, $category, $bedrooms, $guests, $city,
58
                                $district $neighborhood, $title, $address,
59
                                $latitude, $longitude, $price, $priceType];
60
            */
61
            [
62
                $this->getReference('admin'),
63
                $this->getReference('Продава'),
64
                $this->getReference('Вила'),
65
                5,
66
                null,
67
                $this->getReference('Варна'),
68
                $this->getReference('Община Варна'),
69
                $this->getReference('м-т Боровец - Юг'),
70
                'Красива вила за продажба в м-т Боровец - Юг',
71
                'Боровец - Юг',
72
                '43.1467016', '27.8934756', 1000, 'кв. м.',
73
            ],
74
        ];
75
    }
76
77
    private function getPropertyContent(): string
78
    {
79
        return '<p>Много красива вила, находяща се на 13 км. от центъра на Варна в местността Боровец - Юг</p>';
80
    }
81
82
    public function getDependencies()
83
    {
84
        return [
85
            CategoryFixtures::class,
86
            CityFixtures::class,
87
            DealTypeFixtures::class,
88
            DistrictFixtures::class,
89
            FeatureFixtures::class,
90
            NeighborhoodFixtures::class,
91
            UserFixtures::class,
92
        ];
93
    }
94
}
95