Issues (174)

src/Entity/Site.php (3 issues)

Labels
Severity
1
<?php
2
3
namespace Loevgaard\DandomainFoundation\Entity;
4
5
use Assert\Assert;
6
use Doctrine\ORM\Mapping as ORM;
7
use Knp\DoctrineBehaviors\Model\SoftDeletable\SoftDeletable;
8
use Loevgaard\DandomainFoundation\Entity\Generated\CurrencyInterface;
0 ignored issues
show
The type Loevgaard\DandomainFound...rated\CurrencyInterface was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
9
use Loevgaard\DandomainFoundation\Entity\Generated\SiteInterface;
0 ignored issues
show
The type Loevgaard\DandomainFound...Generated\SiteInterface was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
10
use Loevgaard\DandomainFoundation\Entity\Generated\SiteTrait;
0 ignored issues
show
The type Loevgaard\DandomainFound...ity\Generated\SiteTrait was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
11
12
/**
13
 * @ORM\Entity()
14
 * @ORM\Table(name="ldf_sites")
15
 */
16
class Site extends AbstractEntity implements SiteInterface
17
{
18
    use SiteTrait;
19
    use SoftDeletable;
20
21
    protected $hydrateConversions = [
22
        'id' => 'externalId',
23
    ];
24
25
    /**
26
     * @var int
27
     *
28
     * @ORM\Id
29
     * @ORM\GeneratedValue
30
     * @ORM\Column(type="integer")
31
     **/
32
    protected $id;
33
34
    /**
35
     * @var int
36
     *
37
     * @ORM\Column(type="integer", unique=true)
38
     */
39
    protected $externalId;
40
41
    /**
42
     * @var int|null
43
     *
44
     * @ORM\Column(nullable=true, type="integer")
45
     */
46
    protected $countryId;
47
48
    /**
49
     * The currency code in the Dandomain API refers in fact to the currencies' field named 'id' or 'code'
50
     * Therefore we don't have a currencyCode property, but a currency property.
51
     *
52
     * @var CurrencyInterface|null
53
     *
54
     * @ORM\ManyToOne(targetEntity="Currency")
55
     * @ORM\JoinColumn(nullable=false)
56
     */
57
    protected $currency;
58
59
    /**
60
     * @var string|null
61
     *
62
     * @ORM\Column(nullable=true, type="string", length=191)
63
     */
64
    protected $name;
65
66
    /**
67
     * @ORM\PrePersist()
68
     * @ORM\PreUpdate()
69
     */
70
    public function validate()
71
    {
72
        Assert::that($this->externalId)->integer();
73
        Assert::thatNullOr($this->countryId)->integer();
74
        Assert::that($this->currency)->isInstanceOf(CurrencyInterface::class);
75
        Assert::thatNullOr($this->name)->string();
76
    }
77
78 4
    /**
79
     * @return int
80 4
     */
81 2
    public function getId(): int
82
    {
83 2
        return (int) $this->id;
84
    }
85
86
    /**
87
     * @param int $id
88 2
     *
89
     * @return SiteInterface
90 2
     */
91 1
    public function setId($id)
92 2
    {
93 1
        $this->id = $id;
94
95 5
        return $this;
96
    }
97 4
98
    /**
99
     * @return int
100
     */
101 2
    public function getExternalId(): int
102
    {
103 2
        return (int) $this->externalId;
104
    }
105 2
106
    /**
107 2
     * @param int $externalId
108
     *
109 2
     * @return SiteInterface
110
     */
111 1
    public function setExternalId($externalId)
112
    {
113 1
        $this->externalId = $externalId;
114
115 3
        return $this;
116
    }
117 2
118
    /**
119
     * @return int|null
120
     */
121 1
    public function getCountryId()
122
    {
123 1
        return $this->countryId;
124
    }
125 2
126
    /**
127 2
     * @param int|null $countryId
128
     *
129 2
     * @return SiteInterface
130
     */
131 1
    public function setCountryId($countryId)
132
    {
133 1
        $this->countryId = $countryId;
134
135 1
        return $this;
136
    }
137
138
    /**
139
     * @return CurrencyInterface|null
140
     */
141
    public function getCurrency(): ?CurrencyInterface
142
    {
143
        return $this->currency;
144
    }
145
146
    /**
147
     * @param CurrencyInterface|null $currency
148
     *
149
     * @return Site
150 2
     */
151
    public function setCurrency(?CurrencyInterface $currency)
152 2
    {
153
        $this->currency = $currency;
154
155
        return $this;
156
    }
157
158
    /**
159
     * @return null|string
160 2
     */
161 1
    public function getName()
162 2
    {
163 1
        return $this->name;
164 2
    }
165
166
    /**
167
     * @param null|string $name
168
     *
169
     * @return SiteInterface
170
     */
171 1
    public function setName($name)
172
    {
173 1
        $this->name = $name;
174
175 1
        return $this;
176
    }
177
}
178