Completed
Pull Request — 4.0 (#3566)
by k-yamamura
06:23
created

ClassCategory   A

Complexity

Total Complexity 18

Size/Duplication

Total Lines 283
Duplicated Lines 100 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 84.62%

Importance

Changes 0
Metric Value
dl 283
loc 283
ccs 33
cts 39
cp 0.8462
rs 10
c 0
b 0
f 0
wmc 18
lcom 0
cbo 1

18 Methods

Rating   Name   Duplication   Size   Complexity  
A __toString() 4 4 1
A getId() 4 4 1
A setBackendName() 6 6 1
A getBackendName() 4 4 1
A setName() 6 6 1
A getName() 4 4 1
A setSortNo() 6 6 1
A getSortNo() 4 4 1
A setCreateDate() 6 6 1
A getCreateDate() 4 4 1
A setUpdateDate() 6 6 1
A getUpdateDate() 4 4 1
A setClassName() 6 6 1
A getClassName() 4 4 1
A setCreator() 6 6 1
A getCreator() 4 4 1
A setVisible() 6 6 1
A isVisible() 4 4 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php
2
3
/*
4
 * This file is part of EC-CUBE
5
 *
6
 * Copyright(c) LOCKON CO.,LTD. All Rights Reserved.
7
 *
8
 * http://www.lockon.co.jp/
9
 *
10
 * For the full copyright and license information, please view the LICENSE
11
 * file that was distributed with this source code.
12
 */
13
14
namespace Eccube\Entity;
15
16
use Doctrine\ORM\Mapping as ORM;
17
18 1 View Code Duplication
if (!class_exists('\Eccube\Entity\ClassCategory')) {
19
    /**
20
     * ClassCategory
21
     *
22
     * @ORM\Table(name="dtb_class_category")
23
     * @ORM\InheritanceType("SINGLE_TABLE")
24
     * @ORM\DiscriminatorColumn(name="discriminator_type", type="string", length=255)
25
     * @ORM\HasLifecycleCallbacks()
26
     * @ORM\Entity(repositoryClass="Eccube\Repository\ClassCategoryRepository")
27
     */
28
    class ClassCategory extends \Eccube\Entity\AbstractEntity
29
    {
30
        /**
31
         * @return string
32
         */
33 71
        public function __toString()
34
        {
35 71
            return (string) $this->getName();
36
        }
37
38
        /**
39
         * @var int
40
         *
41
         * @ORM\Column(name="id", type="integer", options={"unsigned":true})
42
         * @ORM\Id
43
         * @ORM\GeneratedValue(strategy="IDENTITY")
44
         */
45
        private $id;
46
47
        /**
48
         * @var string
49
         *
50
         * @ORM\Column(name="backend_name", type="string", length=255, nullable=true)
51
         */
52
        private $backend_name;
53
54
        /**
55
         * @var string
56
         *
57
         * @ORM\Column(name="name", type="string", length=255)
58
         */
59
        private $name;
60
61
        /**
62
         * @var int
63
         *
64
         * @ORM\Column(name="sort_no", type="integer")
65
         */
66
        private $sort_no;
67
68
        /**
69
         * @var boolean
70
         *
71
         * @ORM\Column(name="visible", type="boolean", options={"default":true})
72
         */
73
        private $visible;
74
75
        /**
76
         * @var \DateTime
77
         *
78
         * @ORM\Column(name="create_date", type="datetimetz")
79
         */
80
        private $create_date;
81
82
        /**
83
         * @var \DateTime
84
         *
85
         * @ORM\Column(name="update_date", type="datetimetz")
86
         */
87
        private $update_date;
88
89
        /**
90
         * @var \Eccube\Entity\ClassName
91
         *
92
         * @ORM\ManyToOne(targetEntity="Eccube\Entity\ClassName", inversedBy="ClassCategories")
93
         * @ORM\JoinColumns({
94
         *   @ORM\JoinColumn(name="class_name_id", referencedColumnName="id")
95
         * })
96
         */
97
        private $ClassName;
98
99
        /**
100
         * @var \Eccube\Entity\Member
101
         *
102
         * @ORM\ManyToOne(targetEntity="Eccube\Entity\Member")
103
         * @ORM\JoinColumns({
104
         *   @ORM\JoinColumn(name="creator_id", referencedColumnName="id")
105
         * })
106
         */
107 107
        private $Creator;
108
109 107
        /**
110
         * Get id.
111
         *
112
         * @return int
113
         */
114
        public function getId()
115
        {
116
            return $this->id;
117
        }
118
119 21
        /**
120
         * Set backend_name.
121 21
         *
122
         * @param string $backendName
123 21
         *
124
         * @return ClassCategory
125
         */
126
        public function setBackendName($backendName)
127
        {
128
            $this->backend_name = $backendName;
129
130
            return $this;
131 284
        }
132
133 284
        /**
134
         * Get backend_name.
135
         *
136
         * @return string
137
         */
138
        public function getBackendName()
139
        {
140
            return $this->backend_name;
141
        }
142
143 21
        /**
144
         * Set name.
145 21
         *
146
         * @param string $name
147 21
         *
148
         * @return ClassCategory
149
         */
150
        public function setName($name)
151
        {
152
            $this->name = $name;
153
154
            return $this;
155 9
        }
156
157 9
        /**
158
         * Get name.
159
         *
160
         * @return string
161
         */
162
        public function getName()
163
        {
164
            return $this->name;
165
        }
166
167 18
        /**
168
         * Set sortNo.
169 18
         *
170
         * @param int $sortNo
171 18
         *
172
         * @return ClassCategory
173
         */
174
        public function setSortNo($sortNo)
175
        {
176
            $this->sort_no = $sortNo;
177
178
            return $this;
179
        }
180
181
        /**
182
         * Get sortNo.
183
         *
184
         * @return int
185
         */
186
        public function getSortNo()
187
        {
188
            return $this->sort_no;
189
        }
190
191 21
        /**
192
         * Set createDate.
193 21
         *
194
         * @param \DateTime $createDate
195 21
         *
196
         * @return ClassCategory
197
         */
198
        public function setCreateDate($createDate)
199
        {
200
            $this->create_date = $createDate;
201
202
            return $this;
203
        }
204
205
        /**
206
         * Get createDate.
207
         *
208
         * @return \DateTime
209
         */
210
        public function getCreateDate()
211
        {
212
            return $this->create_date;
213
        }
214
215 20
        /**
216
         * Set updateDate.
217 20
         *
218
         * @param \DateTime $updateDate
219 20
         *
220
         * @return ClassCategory
221
         */
222
        public function setUpdateDate($updateDate)
223
        {
224
            $this->update_date = $updateDate;
225
226
            return $this;
227 273
        }
228
229 273
        /**
230
         * Get updateDate.
231
         *
232
         * @return \DateTime
233
         */
234
        public function getUpdateDate()
235
        {
236
            return $this->update_date;
237
        }
238
239 10
        /**
240
         * Set className.
241 10
         *
242
         * @param \Eccube\Entity\ClassName|null $className
243 10
         *
244
         * @return ClassCategory
245
         */
246
        public function setClassName(\Eccube\Entity\ClassName $className = null)
247
        {
248
            $this->ClassName = $className;
249
250
            return $this;
251
        }
252
253
        /**
254
         * Get className.
255
         *
256
         * @return \Eccube\Entity\ClassName|null
257
         */
258
        public function getClassName()
259
        {
260
            return $this->ClassName;
261
        }
262
263 18
        /**
264
         * Set creator.
265 18
         *
266
         * @param \Eccube\Entity\Member|null $creator
267 18
         *
268
         * @return ClassCategory
269
         */
270
        public function setCreator(\Eccube\Entity\Member $creator = null)
271
        {
272
            $this->Creator = $creator;
273
274
            return $this;
275 98
        }
276
277 98
        /**
278
         * Get creator.
279
         *
280
         * @return \Eccube\Entity\Member|null
281
         */
282
        public function getCreator()
283
        {
284
            return $this->Creator;
285
        }
286
287
        /**
288
         * Set visible
289
         *
290
         * @param boolean $visible
291
         *
292
         * @return ClassCategory
293
         */
294
        public function setVisible($visible)
295
        {
296
            $this->visible = $visible;
297
298
            return $this;
299
        }
300
301
        /**
302
         * Is the visibility visible?
303
         *
304
         * @return boolean
305
         */
306
        public function isVisible()
307
        {
308
            return $this->visible;
309
        }
310
    }
311
}
312