Passed
Push — master ( 6957cf...3bb145 )
by Joachim
04:59
created

ReportConfiguration::__toString()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Setono\SyliusStockMovementPlugin\Model;
6
7
use Cron\CronExpression;
8
use Doctrine\Common\Collections\ArrayCollection;
9
use Doctrine\Common\Collections\Collection;
10
11
class ReportConfiguration implements ReportConfigurationInterface
12
{
13
    /** @var int */
14
    protected $id;
15
16
    /** @var string */
17
    protected $name;
18
19
    /** @var CronExpression */
20
    protected $schedule;
21
22
    /** @var string */
23
    protected $template;
24
25
    /** @var ReportConfigurationFilterInterface[]|Collection */
26
    protected $filters;
27
28
    /** @var ReportConfigurationTransportInterface[]|Collection */
29
    protected $transports;
30
31
    public function __construct()
32
    {
33
        $this->filters = new ArrayCollection();
34
        $this->transports = new ArrayCollection();
35
    }
36
37
    public function __toString(): string
38
    {
39
        return (string) $this->getName();
40
    }
41
42
    public function getId(): ?int
43
    {
44
        return $this->id;
45
    }
46
47
    public function getName(): ?string
48
    {
49
        return $this->name;
50
    }
51
52
    public function setName(string $name): void
53
    {
54
        $this->name = $name;
55
    }
56
57
    public function getSchedule(): ?CronExpression
58
    {
59
        return $this->schedule;
60
    }
61
62
    public function setSchedule(CronExpression $schedule): void
63
    {
64
        $this->schedule = $schedule;
65
    }
66
67
    public function getTemplate(): ?string
68
    {
69
        return $this->template;
70
    }
71
72
    public function setTemplate(string $template): void
73
    {
74
        $this->template = $template;
75
    }
76
77
    public function getFilters(): Collection
78
    {
79
        return $this->filters;
80
    }
81
82
    public function hasFilters(): bool
83
    {
84
        return !$this->filters->isEmpty();
85
    }
86
87
    public function hasFilter(ReportConfigurationFilterInterface $transport): bool
88
    {
89
        return $this->filters->contains($transport);
90
    }
91
92
    public function addFilter(ReportConfigurationFilterInterface $transport): void
93
    {
94
        if (!$this->hasFilter($transport)) {
95
            $transport->setReportConfiguration($this);
96
            $this->filters->add($transport);
97
        }
98
    }
99
100
    public function removeFilter(ReportConfigurationFilterInterface $transport): void
101
    {
102
        $transport->setReportConfiguration(null);
103
        $this->filters->removeElement($transport);
104
    }
105
106
    public function getTransports(): Collection
107
    {
108
        return $this->transports;
109
    }
110
111
    public function hasTransports(): bool
112
    {
113
        return !$this->transports->isEmpty();
114
    }
115
116
    public function hasTransport(ReportConfigurationTransportInterface $transport): bool
117
    {
118
        return $this->transports->contains($transport);
119
    }
120
121
    public function addTransport(ReportConfigurationTransportInterface $transport): void
122
    {
123
        if (!$this->hasTransport($transport)) {
124
            $transport->setReportConfiguration($this);
125
            $this->transports->add($transport);
126
        }
127
    }
128
129
    public function removeTransport(ReportConfigurationTransportInterface $transport): void
130
    {
131
        $transport->setReportConfiguration(null);
132
        $this->transports->removeElement($transport);
133
    }
134
}
135