Schema   A
last analyzed

Complexity

Total Complexity 8

Size/Duplication

Total Lines 97
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 12
Bugs 5 Features 2
Metric Value
wmc 8
c 12
b 5
f 2
lcom 1
cbo 2
dl 0
loc 97
rs 10

8 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A __toString() 0 4 1
A getId() 0 4 1
A addDefinition() 0 7 1
A removeDefinition() 0 4 1
A getDefinitions() 0 4 1
A setClassName() 0 6 1
A getClassName() 0 4 1
1
<?php
2
3
namespace Padam87\AttributeBundle\Entity;
4
5
use Doctrine\Common\Collections\ArrayCollection;
6
use Doctrine\ORM\Mapping as ORM;
7
use Symfony\Component\Validator\Constraints as Assert;
8
9
/**
10
 * @ORM\Entity()
11
 * @ORM\Table("attribute_schema")
12
 */
13
class Schema
14
{
15
    /**
16
     * @var int
17
     *
18
     * @ORM\Id
19
     * @ORM\Column(type="integer")
20
     * @ORM\GeneratedValue(strategy="AUTO")
21
     */
22
    protected $id;
23
24
    /**
25
     * @var string
26
     *
27
     * @ORM\Column(type="string", length=255)
28
     */
29
    private $className;
30
31
    /**
32
     * @var ArrayCollection
33
     *
34
     * @Assert\Valid
35
     * @ORM\OneToMany(targetEntity="Definition", mappedBy="schema", orphanRemoval=true, cascade={"persist", "remove"})
36
     * @ORM\OrderBy({"orderIndex" = "ASC"})
37
     */
38
    protected $definitions;
39
40
    public function __construct()
41
    {
42
        $this->definitions = new ArrayCollection();
43
    }
44
45
    /**
46
     * @return mixed
47
     */
48
    public function __toString()
49
    {
50
        return $this->className;
51
    }
52
53
    /**
54
     * @return integer
55
     */
56
    public function getId()
57
    {
58
        return $this->id;
59
    }
60
61
    /**
62
     * @param Definition $definition
63
     *
64
     * @return Schema
65
     */
66
    public function addDefinition(Definition $definition)
67
    {
68
        $definition->setSchema($this);
69
        $this->definitions[] = $definition;
70
71
        return $this;
72
    }
73
74
    /**
75
     * @param Definition $definitions
76
     */
77
    public function removeDefinition(Definition $definitions)
78
    {
79
        $this->definitions->removeElement($definitions);
80
    }
81
82
    /**
83
     * @return ArrayCollection
84
     */
85
    public function getDefinitions()
86
    {
87
        return $this->definitions;
88
    }
89
90
    /**
91
     * @param string $className
92
     *
93
     * @return Schema
94
     */
95
    public function setClassName($className)
96
    {
97
        $this->className = $className;
98
99
        return $this;
100
    }
101
102
    /**
103
     * @return string
104
     */
105
    public function getClassName()
106
    {
107
        return $this->className;
108
    }
109
}
110