Completed
Push — master ( d9fe77...6645ab )
by Jan
04:48
created

Footprint::getFilename()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
c 0
b 0
f 0
nc 1
nop 0
dl 0
loc 3
rs 10
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\Attachments\Attachment;
65
use App\Entity\Attachments\FootprintAttachment;
66
use App\Entity\Base\PartsContainingDBElement;
67
use Doctrine\Common\Collections\Collection;
68
use Doctrine\ORM\Mapping as ORM;
69
70
/**
71
 * Class Footprint.
72
 *
73
 * @ORM\Entity(repositoryClass="App\Repository\StructuralDBElementRepository")
74
 * @ORM\Table("`footprints`")
75
 */
76
class Footprint extends PartsContainingDBElement
77
{
78
    /**
79
     * @var Collection|FootprintAttachment[]
80
     * @ORM\OneToMany(targetEntity="App\Entity\Attachments\FootprintAttachment", mappedBy="element", cascade={"persist", "remove"}, orphanRemoval=true)
81
     */
82
    protected $attachments;
83
84
    /**
85
     * @ORM\OneToMany(targetEntity="Footprint", mappedBy="parent")
86
     */
87
    protected $children;
88
89
    /**
90
     * @ORM\ManyToOne(targetEntity="Footprint", inversedBy="children")
91
     * @ORM\JoinColumn(name="parent_id", referencedColumnName="id")
92
     */
93
    protected $parent;
94
95
    /**
96
     * @ORM\OneToMany(targetEntity="Part", mappedBy="footprint", fetch="EXTRA_LAZY")
97
     */
98
    protected $parts;
99
100
    /**
101
     * @var FootprintAttachment|null
102
     * @ORM\ManyToOne(targetEntity="App\Entity\Attachments\FootprintAttachment")
103
     * @ORM\JoinColumn(name="id_footprint_3d", referencedColumnName="id")
104
     */
105
    protected $footprint_3d;
106
107
    /**
108
     * Returns the ID as an string, defined by the element class.
109
     * This should have a form like P000014, for a part with ID 14.
110
     *
111
     * @return string The ID as a string;
112
     */
113
    public function getIDString(): string
114
    {
115
        return 'F'.sprintf('%06d', $this->getID());
116
    }
117
118
    /****************************************
119
     * Getters
120
     ****************************************/
121
122
    /**
123
     * Returns the 3D Model associated with this footprint.
124
     * @return FootprintAttachment|null
125
     */
126
    public function getFootprint3d() : ?FootprintAttachment
127
    {
128
        return $this->footprint_3d;
129
    }
130
131
    /********************************************************************************
132
     *
133
     *   Setters
134
     *
135
     *********************************************************************************/
136
137
    /**
138
     * Sets the 3D Model associated with this footprint.
139
     * @param FootprintAttachment|null $new_attachment
140
     * @return Footprint
141
     */
142
    public function setFootprint3d(?FootprintAttachment $new_attachment) : Footprint
143
    {
144
        $this->footprint_3d = $new_attachment;
145
        return $this;
146
    }
147
148
}
149