Completed
Pull Request — master (#30)
by
unknown
03:36
created

DtoEvent::setGoogleEventId()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

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 6
rs 9.4285
ccs 0
cts 5
cp 0
cc 1
eloc 3
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 $user
12
     *
13
     * @var Assert\NotBlank
14
     */
15
    private $user;
16
17
    private $summary;
18
19
    private $description;
20
21
    private $location;
22
23
    /**
24
     * @var Assert\NotBlank
25
     */
26
    private $start;
27
28
    /**
29
     * @var Assert\NotBlank
30
     */
31
    private $end;
32
33
    private $googleEventId;
34
35
    public function __construct(\Google_Service_Calendar_Event $event = null)
36
    {
37
        if ($event && $event instanceof \Google_Service_Calendar_Event) {
38
            $this->summary = $event->getSummary();
39
            $this->description = $event->getDescription();
40
            $this->summary = $event->getSummary();
41
            $this->location = $event->getLocation();
42
            $this->start = $event->getStart();
43
            $this->end = $event->getEnd();
44
            $this->googleEventId = $event->getId();
45
        }
46
    }
47
48
    public function jsonSerialize()
49
    {
50
        $description = json_decode($this->description, true);
51
        return [
52
            'user' => (int)$description['user'],
53
            'summary' => $this->summary,
54
            'description' => $description['description'],
55
            'location' => $this->location,
56
            'start' => $this->start->dateTime,
57
            'end' => $this->end->dateTime,
58
            'googleEventId' => $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