Completed
Push — sf2.7 ( cc13d7...fb6965 )
by Laurent
04:29
created

Supplier::setSlug()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 5
rs 9.4285
cc 1
eloc 3
nc 1
nop 1
1
<?php
2
3
/**
4
 * Entité Supplier.
5
 *
6
 * PHP Version 5
7
 *
8
 * @author     Quétier Laurent <[email protected]>
9
 * @copyright  2014 Dev-Int GLSR
10
 * @license    http://opensource.org/licenses/gpl-license.php GNU Public License
11
 *
12
 * @version    since 1.0.0
13
 *
14
 * @link       https://github.com/Dev-Int/glsr
15
 */
16
namespace AppBundle\Entity;
17
18
use Doctrine\ORM\Mapping as ORM;
19
use Symfony\Component\Validator\Constraints as Assert;
20
use Gedmo\Mapping\Annotation as Gedmo;
21
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
22
use AppBundle\Entity\Contact;
23
use AppBundle\Entity\FamilyLog;
24
25
/**
26
 * Supplier Entité Supplier.
27
 *
28
 * @category   Entity
29
 *
30
 * @ORM\Table(name="gs_supplier")
31
 * @ORM\Entity(repositoryClass="AppBundle\Entity\SupplierRepository")
32
 * @UniqueEntity(
33
 *     fields="name",
34
 *     message="Ce nom de fournisseur est déjà utilisé dans le système."
35
 * )
36
 */
37
class Supplier extends Contact
38
{
39
    /**
40
     * @var int id du fournisseur
41
     *
42
     * @ORM\Column(name="id", type="integer")
43
     * @ORM\Id
44
     * @ORM\GeneratedValue(strategy="AUTO")
45
     */
46
    private $id;
47
48
    /**
49
     * @var string Famille logistique
50
     * @ORM\ManyToOne(targetEntity="AppBundle\Entity\FamilyLog")
51
     * @Assert\NotBlank()
52
     */
53
    private $family_log;
54
55
    /**
56
     * @var int Délai de livraison
57
     *
58
     * @ORM\Column(name="delaydeliv", type="smallint")
59
     * @Assert\Length(
60
     *     max="1",
61
     *     maxMessage = "Votre choix ne peut pas être que {{ limit }} caractère"
62
     * )
63
     * @Assert\NotBlank()
64
     */
65
    private $delaydeliv;
66
67
    /**
68
     * @var array Tableau des jours de commande
69
     *
70
     * @ORM\Column(name="orderdate", type="simple_array")
71
     * @Assert\NotBlank(message="Il vous faut choisir au moins 1 date de commande.")
72
     */
73
    private $orderdate;
74
75
    /**
76
     * @var bool Activé/Désactivé
77
     *
78
     * @ORM\Column(name="active", type="boolean")
79
     */
80
    private $active;
81
82
    /**
83
     * @Gedmo\Slug(fields={"name"}, updatable=false)
84
     * @ORM\Column(length=128, unique=true)
85
     */
86
    private $slug;
87
88
    /**
89
     * __construct.
90
     */
91
    public function __construct()
92
    {
93
        $this->active = true;
94
    }
95
96
    /**
97
     * Get id
98
     *
99
     * @return integer
100
     */
101
    public function getId()
102
    {
103
        return $this->id;
104
    }
105
106
    /**
107
     * Set delaydeliv.
108
     *
109
     * @param int $delaydeliv Délai de livraison
110
     *
111
     * @return Supplier
112
     */
113
    public function setDelaydeliv($delaydeliv)
114
    {
115
        $this->delaydeliv = $delaydeliv;
116
        return $this;
117
    }
118
119
    /**
120
     * Get delaydeliv.
121
     *
122
     * @return int
123
     */
124
    public function getDelaydeliv()
125
    {
126
        return $this->delaydeliv;
127
    }
128
129
    /**
130
     * Set orderdate.
131
     *
132
     * @param array $orderdate Jour(s) de commande
133
     *
134
     * @return Supplier
135
     */
136
    public function setOrderdate($orderdate)
137
    {
138
        $this->orderdate = $orderdate;
139
        return $this;
140
    }
141
    /**
142
     * Get orderdate.
143
     *
144
     * @return array
145
     */
146
    public function getOrderdate()
147
    {
148
        return $this->orderdate;
149
    }
150
151
    /**
152
     * Set family_log.
153
     *
154
     * @param FamilyLog $familyLog Famille logistique
155
     *
156
     * @return Supplier
157
     */
158
    public function setFamilyLog(FamilyLog $familyLog = null)
159
    {
160
        $this->family_log = $familyLog;
0 ignored issues
show
Documentation Bug introduced by
It seems like $familyLog can also be of type object<AppBundle\Entity\FamilyLog>. However, the property $family_log is declared as type string. Maybe add an additional type check?

Our type inference engine has found a suspicous assignment of a value to a property. This check raises an issue when a value that can be of a mixed type is assigned to a property that is type hinted more strictly.

For example, imagine you have a variable $accountId that can either hold an Id object or false (if there is no account id yet). Your code now assigns that value to the id property of an instance of the Account class. This class holds a proper account, so the id value must no longer be false.

Either this assignment is in error or a type check should be added for that assignment.

class Id
{
    public $id;

    public function __construct($id)
    {
        $this->id = $id;
    }

}

class Account
{
    /** @var  Id $id */
    public $id;
}

$account_id = false;

if (starsAreRight()) {
    $account_id = new Id(42);
}

$account = new Account();
if ($account instanceof Id)
{
    $account->id = $account_id;
}
Loading history...
161
        return $this;
162
    }
163
164
    /**
165
     * Get family_log.
166
     *
167
     * @return FamilyLog
168
     */
169
    public function getFamilyLog()
170
    {
171
        return $this->family_log;
172
    }
173
174
    /**
175
     * Get slug
176
     *
177
     * @return string
178
     */
179
    public function getSlug()
180
    {
181
        return $this->slug;
182
    }
183
184
    /**
185
     * Cette méthode permet de faire "echo $supplier".
186
     * <p>Ainsi, pour "afficher" $supplier,
187
     * PHP affichera en réalité le retour de cette méthode.<br />
188
     * Ici, le nom, donc "echo $supplier"
189
     * est équivalent à "echo $supplier->getName()"</p>.
190
     *
191
     * @return string name
192
     */
193
    public function __toString()
194
    {
195
        return $this->getName();
196
    }
197
198
    /**
199
     * Set active.
200
     *
201
     * @param bool $active Activé/Désactivé
202
     *
203
     * @return Supplier
204
     */
205
    public function setActive($active)
206
    {
207
        $this->active = $active;
208
        return $this;
209
    }
210
211
    /**
212
     * Is active.
213
     *
214
     * @return bool
215
     */
216
    public function isActive()
217
    {
218
        return $this->active;
219
    }
220
}
221