Completed
Push — feature/middleware ( a35412...bb427e )
by Derek Stephen
03:50
created

Dragon   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 77
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 0
Metric Value
wmc 7
lcom 1
cbo 0
dl 0
loc 77
rs 10
c 0
b 0
f 0

7 Methods

Rating   Name   Duplication   Size   Complexity  
A getId() 0 4 1
A setId() 0 4 1
A getName() 0 4 1
A setName() 0 4 1
A toArray() 0 9 1
A toJson() 0 4 1
A __toString() 0 4 1
1
<?php
2
3
namespace BoneMvc\Module\Dragon\Entity;
4
5
use Doctrine\ORM\Mapping as ORM;
6
7
/**
8
 * @ORM\Entity(repositoryClass="\BoneMvc\Module\Repository\DragonRepository")
9
 */
10
class Dragon
11
{
12
    /**
13
     * @var int $id
14
     * @ORM\Id
15
     * @ORM\Column(type="integer")
16
     * @ORM\GeneratedValue
17
     */
18
    private $id;
19
20
    /**
21
     * @var string $name
22
     * @ORM\Column(type="string", length=30, nullable=false)
23
     */
24
    private $name;
25
26
    /**
27
     * @return int
28
     */
29
    public function getId()
30
    {
31
        return $this->id;
32
    }
33
34
    /**
35
     * @param int $id
36
     */
37
    public function setId($id)
38
    {
39
        $this->id = $id;
40
    }
41
42
    /**
43
     * @return string
44
     */
45
    public function getName(): ?string
46
    {
47
        return $this->name;
48
    }
49
50
    /**
51
     * @param string $name
52
     */
53
    public function setName(string $name)
54
    {
55
        $this->name = $name;
56
    }
57
58
    /**
59
     * @return array
60
     */
61
    public function toArray()
62
    {
63
        $data = [
64
            'id' => $this->getId(),
65
            'name' => $this->getName(),
66
        ];
67
68
        return $data;
69
    }
70
71
    /**
72
     * @return string
73
     */
74
    public function toJson()
75
    {
76
        return \json_encode($this->toArray());
77
    }
78
79
    /**
80
     * @return string
81
     */
82
    public function __toString()
83
    {
84
        return $this->toJson();
85
    }
86
}
87