Passed
Push — master ( 727abb...ceefce )
by Yannick
07:55 queued 14s
created

Sequence   A

Complexity

Total Complexity 9

Size/Duplication

Total Lines 78
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 24
dl 0
loc 78
rs 10
c 0
b 0
f 0
wmc 9

9 Methods

Rating   Name   Duplication   Size   Complexity  
A getUnSerializeGraph() 0 3 1
A setGraphAndSerialize() 0 5 1
A setGraph() 0 5 1
A getGraph() 0 3 1
A hasGraph() 0 3 1
A getId() 0 3 1
A __toString() 0 3 1
A getTitle() 0 3 1
A setTitle() 0 5 1
1
<?php
2
3
declare(strict_types=1);
4
5
/* For licensing terms, see /license.txt */
6
7
namespace Chamilo\CoreBundle\Entity;
8
9
use Chamilo\CoreBundle\Repository\SequenceRepository;
10
use Doctrine\ORM\Mapping as ORM;
11
use Fhaculty\Graph\Graph;
12
use Gedmo\Timestampable\Traits\TimestampableEntity;
13
use Stringable;
14
15
#[ORM\Table(name: 'sequence')]
16
#[ORM\Entity(repositoryClass: SequenceRepository::class)]
17
class Sequence implements Stringable
18
{
19
    use TimestampableEntity;
20
21
    #[ORM\Column(name: 'id', type: 'integer')]
22
    #[ORM\Id]
23
    #[ORM\GeneratedValue]
24
    protected ?int $id = null;
25
26
    #[ORM\Column(name: 'title', type: 'string')]
27
    protected string $title;
28
29
    #[ORM\Column(name: 'graph', type: 'text', nullable: true)]
30
    protected ?string $graph = null;
31
32
    public function __toString(): string
33
    {
34
        return $this->title;
35
    }
36
37
    /**
38
     * @return int
39
     */
40
    public function getId()
41
    {
42
        return $this->id;
43
    }
44
45
    /**
46
     * @return string
47
     */
48
    public function getTitle()
49
    {
50
        return $this->title;
51
    }
52
53
    public function setTitle(string $title): self
54
    {
55
        $this->title = $title;
56
57
        return $this;
58
    }
59
60
    /**
61
     * @return string
62
     */
63
    public function getGraph()
64
    {
65
        return $this->graph;
66
    }
67
68
    public function setGraph(string $graph): self
69
    {
70
        $this->graph = $graph;
71
72
        return $this;
73
    }
74
75
    public function hasGraph(): bool
76
    {
77
        return !empty($this->graph);
78
    }
79
80
    /**
81
     * @return Graph
82
     */
83
    public function getUnSerializeGraph()
84
    {
85
        return unserialize($this->graph);
86
    }
87
88
    public function setGraphAndSerialize(Graph $graph): self
89
    {
90
        $this->setGraph(serialize($graph));
91
92
        return $this;
93
    }
94
}
95