Completed
Pull Request — master (#30)
by
unknown
04:24
created

DtoEvent::setDescription()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 4
rs 10
ccs 0
cts 4
cp 0
cc 1
eloc 2
nc 1
nop 1
crap 2
1
<?php
2
3
namespace AppBundle\Entity\DTO;
4
5
use AppBundle\Entity\User;
6
use Symfony\Component\Validator\Constraints as Assert;
7
8
class DtoEvent implements \JsonSerializable
9
{
10
    /**
11
     * @var User
12
     * @var Assert\NotBlank
13
     */
14
    private $user;
15
16
    private $summary;
17
18
    private $description;
19
20
    private $location;
21
22
    /**
23
     * @var Assert\NotBlank
24
     */
25
    private $start;
26
27
    /**
28
     * @var Assert\NotBlank
29
     */
30
    private $end;
31
32
    private $googleEventId;
33
34
    public function __construct(\Google_Service_Calendar_Event $event = null)
35
    {
36
        if ($event && $event instanceof \Google_Service_Calendar_Event) {
37
            $this->summary = $event->getSummary();
38
            $this->description = $event->getDescription();
39
            $this->summary = $event->getSummary();
40
            $this->location = $event->getLocation();
41
            $this->start = $event->getStart();
42
            $this->end = $event->getEnd();
43
            $this->googleEventId = $event->getId();
44
        }
45
    }
46
47
    public function jsonSerialize()
48
    {
49
        $description = json_decode($this->description, true);
50
51
        return [
52
            'user' => (int) $description['user'],
53
            'title' => $this->summary,
54
            'description' => $description['description'],
55
            'location' => $this->location,
56
            'start' => $this->start->dateTime,
57
            'end' => $this->end->dateTime,
58
            'id' => $this->googleEventId,
59
        ];
60
    }
61
62
    /**
63
     * @return mixed
64
     */
65
    public function getSummary()
66
    {
67
        return $this->summary;
68
    }
69
70
    /**
71
     * @param mixed $summary
72
     */
73
    public function setSummary($summary)
74
    {
75
        $this->summary = $summary;
76
    }
77
78
    /**
79
     * @return mixed
80
     */
81
    public function getDescription()
82
    {
83
        return $this->description;
84
    }
85
86
    /**
87
     * @param mixed $description
88
     */
89
    public function setDescription($description)
90
    {
91
        $this->description = $description;
92
    }
93
94
    /**
95
     * @return mixed
96
     */
97
    public function getLocation()
98
    {
99
        return $this->location;
100
    }
101
102
    /**
103
     * @param mixed $location
104
     */
105
    public function setLocation($location)
106
    {
107
        $this->location = $location;
108
    }
109
110
    /**
111
     * @return mixed
112
     */
113
    public function getStart()
114
    {
115
        return $this->start;
116
    }
117
118
    /**
119
     * @param mixed $start
120
     */
121
    public function setStart($start)
122
    {
123
        $this->start = $start;
124
    }
125
126
    /**
127
     * @return mixed
128
     */
129
    public function getEnd()
130
    {
131
        return $this->end;
132
    }
133
134
    /**
135
     * @param mixed $end
136
     */
137
    public function setEnd($end)
138
    {
139
        $this->end = $end;
140
    }
141
142
    /**
143
     * @return User
144
     */
145
    public function getUser()
146
    {
147
        return $this->user;
148
    }
149
150
    /**
151
     * @param User $user
152
     *
153
     * @return $this
154
     */
155
    public function setUser($user)
156
    {
157
        $this->user = $user;
158
159
        return $this;
160
    }
161
162
    /**
163
     * @return mixed
164
     */
165
    public function getGoogleEventId()
166
    {
167
        return $this->googleEventId;
168
    }
169
170
    /**
171
     * @param mixed $googleEventId
172
     *
173
     * @return $this
174
     */
175
    public function setGoogleEventId($googleEventId)
176
    {
177
        $this->googleEventId = $googleEventId;
178
179
        return $this;
180
    }
181
}
182