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

Dragon::setName()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 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