Passed
Push — master ( 33631f...10f39b )
by Jan
03:09
created

DBElement::__clone()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
<?php declare(strict_types=1);
2
/**
3
 *
4
 * Part-DB Version 0.4+ "nextgen"
5
 * Copyright (C) 2016 - 2019 Jan Böhmer
6
 * https://github.com/jbtronics
7
 *
8
 * This program is free software; you can redistribute it and/or
9
 * modify it under the terms of the GNU General Public License
10
 * as published by the Free Software Foundation; either version 2
11
 * of the License, or (at your option) any later version.
12
 *
13
 * This program is distributed in the hope that it will be useful,
14
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
 * GNU General Public License for more details.
17
 *
18
 * You should have received a copy of the GNU General Public License
19
 * along with this program; if not, write to the Free Software
20
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
21
 *
22
 */
23
24
namespace App\Entity;
25
26
use Doctrine\ORM\Mapping as ORM;
27
28
/**
29
 * This class is for managing all database objects.
30
 *
31
 * You should use this class for ALL classes which manages database records!
32
 *          (except special tables like "internal"...)
33
 * Every database table which are managed with this class (or a subclass of it)
34
 *          must have the table row "id"!! The ID is the unique key to identify the elements.
35
 *
36
 * @ORM\MappedSuperclass()
37
 */
38
abstract class DBElement
39
{
40
41
    /** @var int The Identification number for this part. This value is unique for the element in this table.
42
     * @ORM\Column(type="integer")
43
     * @ORM\Id()
44
     * @ORM\GeneratedValue()
45
     */
46
    protected $id;
47
48
    /**
49
     * Get the ID. The ID can be zero, or even negative (for virtual elements). If an elemenent is virtual, can be
50
     * checked with isVirtualElement()
51
     *
52
     * @return integer the ID of this element
53
     */
54
    final public function getID() : int
55
    {
56
        return (int) $this->id;
57
    }
58
59
60
    /**
61
     * Returns the ID as an string, defined by the element class.
62
     * This should have a form like P000014, for a part with ID 14.
63
     * @return string The ID as a string;
64
     */
65
    abstract public function getIDString() : string;
66
67
    public function __clone()
68
    {
69
        //Set ID to null, so that an new entry is created
70
        $this->id = null;
71
    }
72
73
}