Completed
Push — Recipes ( 630f49...c8afb0 )
by Laurent
12:15 queued 03:48
created

Inventory::addArticle()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 6
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
1
<?php
2
/**
3
 * Entity Inventory.
4
 *
5
 * PHP Version 7
6
 *
7
 * @author    Quétier Laurent <[email protected]>
8
 * @copyright 2014 Dev-Int GLSR
9
 * @license   http://opensource.org/licenses/gpl-license.php GNU Public License
10
 *
11
 * @version GIT: <git_id>
12
 *
13
 * @link https://github.com/Dev-Int/glsr
14
 */
15
namespace  App\Entity\Stocks;
16
17
use Doctrine\ORM\Mapping as ORM;
18
use Doctrine\Common\Collections\ArrayCollection;
19
use App\Entity\Stocks\InventoryArticles;
20
21
/**
22
 * Inventory entity.
23
 *
24
 * @category Entity
25
 *
26
 * @ORM\Table(name="gs_inventory")
27
 * @ORM\Entity(repositoryClass="App\Repository\Stocks\InventoryRepository")
28
 */
29
class Inventory
30
{
31
    /**
32
     * @var integer $id Inventory id
33
     *
34
     * @ORM\Column(name="id", type="integer")
35
     * @ORM\Id
36
     * @ORM\GeneratedValue(strategy="AUTO")
37
     */
38
    private $id;
39
40
    /**
41
     * @var \DateTime $date
42
     *
43
     * @ORM\Column(name="date", type="datetime")
44
     */
45
    private $date;
46
47
    /**
48
     * @var integer $status
49
     *
50
     * @ORM\Column(name="status", type="smallint")
51
     */
52
    private $status;
53
54
55
    /**
56
     * @var float $amount Amount of the inventory
57
     *
58
     * @ORM\Column(name="amount", type="decimal", precision=7, scale=3, nullable=true)
59
     */
60
    private $amount;
61
62
    /**
63
     * @var Article $articles Articles of the inventory
64
     * @ORM\OneToMany(targetEntity="App\Entity\Stocks\InventoryArticles", mappedBy="inventory")
65
     * @ORM\JoinColumn(nullable=false)
66
     */
67
    private $articles;
68
69
    public function __construct()
70
    {
71
        $this->articles = new ArrayCollection();
0 ignored issues
show
Documentation Bug introduced by
It seems like new \Doctrine\Common\Collections\ArrayCollection() of type object<Doctrine\Common\C...ctions\ArrayCollection> is incompatible with the declared type object<App\Entity\Stocks\Article> of property $articles.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
72
        $this->date = new \DateTime();
73
        $this->amount = 0.000;
74
        $this->status = 1;
75
    }
76
77
    /**
78
     * Get id
79
     *
80
     * @return integer
81
     */
82
    public function getId()
83
    {
84
        return $this->id;
85
    }
86
87
    /**
88
     * Set date
89
     *
90
     * @param \DateTime $date
91
     * @return Inventory
92
     */
93
    public function setDate(\DateTime $date)
94
    {
95
        $this->date = $date;
96
97
        return $this;
98
    }
99
100
    /**
101
     * Get date
102
     *
103
     * @return \DateTime
104
     */
105
    public function getDate()
106
    {
107
        return $this->date;
108
    }
109
110
    /**
111
     * Set amount
112
     *
113
     * @param float $amount
114
     * @return Inventory
115
     */
116
    public function setAmount($amount)
117
    {
118
        $this->amount = $amount;
119
120
        return $this;
121
    }
122
123
    /**
124
     * Get amount
125
     *
126
     * @return double
127
     */
128
    public function getAmount()
129
    {
130
        return $this->amount;
131
    }
132
133
    /**
134
     * Set status
135
     *
136
     * @param integer $status
137
     * @return Inventory
138
     */
139
    public function setStatus($status)
140
    {
141
        $this->status = $status;
142
143
        return $this;
144
    }
145
146
    /**
147
     * Get status
148
     *
149
     * @return integer
150
     */
151
    public function getStatus()
152
    {
153
        return $this->status;
154
    }
155
156
    /**
157
     * Add articles
158
     *
159
     * @param \App\Entity\Stocks\InventoryArticles $articles
160
     * @return Inventory
161
     */
162
    public function addArticle(InventoryArticles $articles)
163
    {
164
        $this->articles[] = $articles;
165
166
        return $this;
167
    }
168
169
    /**
170
     * Remove articles
171
     *
172
     * @param \App\Entity\Stocks\InventoryArticles $articles
173
     */
174
    public function removeArticle(InventoryArticles $articles)
175
    {
176
        $this->articles->removeElement($articles);
177
    }
178
179
    /**
180
     * Get articles
181
     *
182
     * @return \Doctrine\Common\Collections\ArrayCollection
183
     */
184
    public function getArticles()
185
    {
186
        return $this->articles;
187
    }
188
}
189