Completed
Push — master ( ff858f...0640bf )
by Joachim
13:18
created

Site::setExternalId()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

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