GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

EventCreateRequest::getContent()   A
last analyzed

Complexity

Conditions 3
Paths 4

Size

Total Lines 35
Code Lines 24

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 24
c 1
b 0
f 0
dl 0
loc 35
rs 9.536
cc 3
nc 4
nop 0
1
<?php namespace CalDAVClient\Facade\Requests;
2
/**
3
 * Copyright 2017 OpenStack Foundation
4
 * Licensed under the Apache License, Version 2.0 (the "License");
5
 * you may not use this file except in compliance with the License.
6
 * You may obtain a copy of the License at
7
 * http://www.apache.org/licenses/LICENSE-2.0
8
 * Unless required by applicable law or agreed to in writing, software
9
 * distributed under the License is distributed on an "AS IS" BASIS,
10
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
 * See the License for the specific language governing permissions and
12
 * limitations under the License.
13
 **/
14
15
use CalDAVClient\Facade\Utils\ICalTimeZoneBuilder;
16
use Eluceo\iCal\Component\Event;
17
use DateTime;
18
19
/**
20
 * Class EventCreateRequest
21
 * @package CalDAVClient\Facade\Requests
22
 */
23
class EventCreateRequest implements IAbstractWebDAVRequest
24
{
25
    /**
26
     * @var EventRequestVO
27
     */
28
    private $vo;
29
30
    /**
31
     * EventCreateRequest constructor.
32
     * @param EventRequestVO $vo
33
     */
34
    public function __construct(EventRequestVO $vo)
35
    {
36
        $this->vo = $vo;
37
    }
38
39
    /**
40
     * @return string
41
     */
42
    public function getContent()
43
    {
44
45
        $time_zone        = $this->vo->getTimeZone();
46
        $calendar         = ICalTimeZoneBuilder::build($time_zone, $this->vo->getProdId());
47
        $local_start_time = new DateTime($this->vo->getStartTime()->format('Y-m-d H:i:s'), $time_zone);
48
        $local_end_time   = new DateTime($this->vo->getEndTime()->format('Y-m-d H:i:s'), $time_zone);
49
        $event            = new Event($this->vo->getUID());
50
51
        $event
52
            ->setCreated(new DateTime())
53
            ->setDtStart($local_start_time)
54
            ->setDtEnd($local_end_time)
55
            ->setNoTime(false)
56
            ->setSummary($this->vo->getTitle())
57
            ->setDescription(strip_tags($this->vo->getDescription()))
58
            ->setDescriptionHTML($this->vo->getDescription());
59
60
        if($time_zone->getName() == 'UTC'){
61
            $event->setUseUtc(true)
62
                  ->setUseTimezone(false);
63
        }
64
        else{
65
            $event->setUseUtc(false)
66
                ->setUseTimezone(true);
67
        }
68
69
        if(!empty($this->vo->getLocationTitle())){
70
            $geo = sprintf("%s;%s", $this->vo->getLocationLat(), $this->vo->getLocationLng());
71
            $event->setLocation($this->vo->getLocationTitle(), $this->vo->getLocationTitle(), $geo);
72
        }
73
74
        $calendar->addComponent($event);
75
76
        return $calendar->render();
77
    }
78
}