Completed
Push — master ( bcdba8...408d98 )
by Jan
03:54
created

Storelocation   A

Complexity

Total Complexity 9

Size/Duplication

Total Lines 154
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 21
c 1
b 0
f 0
dl 0
loc 154
rs 10
wmc 9

9 Methods

Rating   Name   Duplication   Size   Complexity  
A setLimitToExistingParts() 0 4 1
A setOnlySinglePart() 0 4 1
A getIDString() 0 3 1
A isFull() 0 3 1
A setIsFull() 0 5 1
A getStorageType() 0 3 1
A setStorageType() 0 4 1
A isOnlySinglePart() 0 3 1
A isLimitToExistingParts() 0 3 1
1
<?php
2
/**
3
 *
4
 * part-db version 0.1
5
 * Copyright (C) 2005 Christoph Lechner
6
 * http://www.cl-projects.de/
7
 *
8
 * part-db version 0.2+
9
 * Copyright (C) 2009 K. Jacobs and others (see authors.php)
10
 * http://code.google.com/p/part-db/
11
 *
12
 * Part-DB Version 0.4+
13
 * Copyright (C) 2016 - 2019 Jan Böhmer
14
 * https://github.com/jbtronics
15
 *
16
 * This program is free software; you can redistribute it and/or
17
 * modify it under the terms of the GNU General Public License
18
 * as published by the Free Software Foundation; either version 2
19
 * of the License, or (at your option) any later version.
20
 *
21
 * This program is distributed in the hope that it will be useful,
22
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
23
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
24
 * GNU General Public License for more details.
25
 *
26
 * You should have received a copy of the GNU General Public License
27
 * along with this program; if not, write to the Free Software
28
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
29
 *
30
 */
31
32
declare(strict_types=1);
33
34
/**
35
 * part-db version 0.1
36
 * Copyright (C) 2005 Christoph Lechner
37
 * http://www.cl-projects.de/.
38
 *
39
 * part-db version 0.2+
40
 * Copyright (C) 2009 K. Jacobs and others (see authors.php)
41
 * http://code.google.com/p/part-db/
42
 *
43
 * Part-DB Version 0.4+
44
 * Copyright (C) 2016 - 2019 Jan Böhmer
45
 * https://github.com/jbtronics
46
 *
47
 * This program is free software; you can redistribute it and/or
48
 * modify it under the terms of the GNU General Public License
49
 * as published by the Free Software Foundation; either version 2
50
 * of the License, or (at your option) any later version.
51
 *
52
 * This program is distributed in the hope that it will be useful,
53
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
54
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
55
 * GNU General Public License for more details.
56
 *
57
 * You should have received a copy of the GNU General Public License
58
 * along with this program; if not, write to the Free Software
59
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
60
 */
61
62
namespace App\Entity\Parts;
63
64
use App\Entity\Base\PartsContainingDBElement;
65
use Doctrine\ORM\Mapping as ORM;
66
67
/**
68
 * Class Storelocation.
69
 *
70
 * @ORM\Entity(repositoryClass="App\Repository\StructuralDBElementRepository")
71
 * @ORM\Table("`storelocations`")
72
 */
73
class Storelocation extends PartsContainingDBElement
74
{
75
    /**
76
     * @ORM\OneToMany(targetEntity="Storelocation", mappedBy="parent")
77
     */
78
    protected $children;
79
80
    /**
81
     * @ORM\ManyToOne(targetEntity="Storelocation", inversedBy="children")
82
     * @ORM\JoinColumn(name="parent_id", referencedColumnName="id")
83
     */
84
    protected $parent;
85
86
    /**
87
     * @ORM\OneToMany(targetEntity="Part", mappedBy="storelocation")
88
     */
89
    protected $parts;
90
91
    /**
92
     * @var bool
93
     * @ORM\Column(type="boolean")
94
     */
95
    protected $is_full;
96
97
    /**
98
     * @var bool
99
     * @ORM\Column(type="boolean")
100
     */
101
    protected $only_single_part;
102
103
    /**
104
     * @var bool
105
     * @ORM\Column(type="boolean")
106
     */
107
    protected $limit_to_existing_parts;
108
109
    /**
110
     * @var MeasurementUnit|null The measurement unit, which parts can be stored in here
111
     * @ORM\ManyToOne(targetEntity="MeasurementUnit")
112
     * @ORM\JoinColumn(name="storage_type_id", referencedColumnName="id")
113
     */
114
    protected $storage_type;
115
116
    /********************************************************************************
117
     *
118
     *   Getters
119
     *
120
     *********************************************************************************/
121
122
    /**
123
     * Get the "is full" attribute.
124
     *
125
     * When this attribute is set, it is not possible to add additional parts or increase the instock of existing parts.
126
     *
127
     * @return bool * true if the storelocation is full
128
     *              * false if the storelocation isn't full
129
     */
130
    public function isFull(): bool
131
    {
132
        return (bool) $this->is_full;
133
    }
134
135
    /**
136
     * When this property is set, only one part (but many instock) is allowed to be stored in this store location.
137
     *
138
     * @return bool
139
     */
140
    public function isOnlySinglePart(): bool
141
    {
142
        return $this->only_single_part;
143
    }
144
145
    /**
146
     * @param bool $only_single_part
147
     * @return Storelocation
148
     */
149
    public function setOnlySinglePart(bool $only_single_part): Storelocation
150
    {
151
        $this->only_single_part = $only_single_part;
152
        return $this;
153
    }
154
155
    /**
156
     * When this property is set, it is only possible to increase the instock of parts, that are already stored here.
157
     *
158
     * @return bool
159
     */
160
    public function isLimitToExistingParts(): bool
161
    {
162
        return $this->limit_to_existing_parts;
163
    }
164
165
    /**
166
     * @param bool $limit_to_existing_parts
167
     * @return Storelocation
168
     */
169
    public function setLimitToExistingParts(bool $limit_to_existing_parts): Storelocation
170
    {
171
        $this->limit_to_existing_parts = $limit_to_existing_parts;
172
        return $this;
173
    }
174
175
    /**
176
     * @return MeasurementUnit|null
177
     */
178
    public function getStorageType(): ?MeasurementUnit
179
    {
180
        return $this->storage_type;
181
    }
182
183
    /**
184
     * @param MeasurementUnit|null $storage_type
185
     * @return Storelocation
186
     */
187
    public function setStorageType(?MeasurementUnit $storage_type): Storelocation
188
    {
189
        $this->storage_type = $storage_type;
190
        return $this;
191
    }
192
193
194
195
    /********************************************************************************
196
     *
197
     *   Setters
198
     *
199
     *********************************************************************************/
200
201
    /**
202
     * Change the "is full" attribute of this storelocation.
203
     *
204
     *     "is_full" = true means that there is no more space in this storelocation.
205
     *     This attribute is only for information, it has no effect.
206
     *
207
     * @param bool $new_is_full * true means that the storelocation is full
208
     *                          * false means that the storelocation isn't full
209
     * @return Storelocation
210
     */
211
    public function setIsFull(bool $new_is_full): Storelocation
212
    {
213
        $this->is_full = $new_is_full;
214
215
        return $this;
216
    }
217
218
    /**
219
     * Returns the ID as an string, defined by the element class.
220
     * This should have a form like P000014, for a part with ID 14.
221
     *
222
     * @return string The ID as a string;
223
     */
224
    public function getIDString(): string
225
    {
226
        return 'L'.sprintf('%06d', $this->getID());
227
    }
228
}
229