Passed
Push — master ( 9f5a4d...eb071b )
by Jan
04:08
created

ElementCreatedLogEntry   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 7
c 2
b 0
f 0
dl 0
loc 29
rs 10
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A getCreationInstockValue() 0 3 1
A hasCreationInstockValue() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
/**
6
 * This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
7
 *
8
 * Copyright (C) 2019 - 2020 Jan Böhmer (https://github.com/jbtronics)
9
 *
10
 * This program is free software; you can redistribute it and/or
11
 * modify it under the terms of the GNU General Public License
12
 * as published by the Free Software Foundation; either version 2
13
 * of the License, or (at your option) any later version.
14
 *
15
 * This program is distributed in the hope that it will be useful,
16
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18
 * GNU General Public License for more details.
19
 *
20
 * You should have received a copy of the GNU General Public License
21
 * along with this program; if not, write to the Free Software
22
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
23
 */
24
25
namespace App\Entity\LogSystem;
26
27
use App\Entity\Base\AbstractDBElement;
28
use Doctrine\ORM\Mapping as ORM;
29
30
/**
31
 * @ORM\Entity()
32
 */
33
class ElementCreatedLogEntry extends AbstractLogEntry
34
{
35
    protected $typeString = 'element_created';
36
37
    public function __construct(AbstractDBElement $new_element)
38
    {
39
        parent::__construct();
40
        $this->level = self::LEVEL_INFO;
41
        $this->setTargetElement($new_element);
42
    }
43
44
    /**
45
     * Gets the instock when the part was created.
46
     *
47
     * @return string|null
48
     */
49
    public function getCreationInstockValue(): ?string
50
    {
51
        return $this->extra['i'] ?? null;
52
    }
53
54
    /**
55
     * Checks if a creation instock value was saved with this entry.
56
     *
57
     * @return bool
58
     */
59
    public function hasCreationInstockValue(): bool
60
    {
61
        return null !== $this->getCreationInstockValue();
62
    }
63
}
64