Completed
Pull Request — master (#57)
by
unknown
02:26 queued 01:09
created

Link::attendees()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 10
rs 9.9332
c 0
b 0
f 0
cc 2
nc 2
nop 1
1
<?php
2
3
namespace Spatie\CalendarLinks;
4
5
use DateTime;
6
use Spatie\CalendarLinks\Generators\Ics;
7
use Spatie\CalendarLinks\Generators\Yahoo;
8
use Spatie\CalendarLinks\Generators\Google;
9
use Spatie\CalendarLinks\Generators\WebOutlook;
10
use Spatie\CalendarLinks\Exceptions\InvalidLink;
11
12
/**
13
 * @property-read string $title
14
 * @property-read \DateTime $from
15
 * @property-read \DateTime $to
16
 * @property-read string $description
17
 * @property-read string $address
18
 * @property-read bool $allDay
19
 */
20
class Link
21
{
22
    /** @var string */
23
    protected $title;
24
25
    /** @var \DateTime */
26
    protected $from;
27
28
    /** @var \DateTime */
29
    protected $to;
30
31
    /** @var string */
32
    protected $description;
33
34
    /** @var bool */
35
    protected $allDay;
36
37
    /** @var string */
38
    protected $address;
39
40
    /** @var array */
41
    protected $attendees;
42
43
    public function __construct(string $title, DateTime $from, DateTime $to, bool $allDay = false)
44
    {
45
        $this->title = $title;
46
        $this->allDay = $allDay;
47
48
        if ($to < $from) {
49
            throw InvalidLink::invalidDateRange($from, $to);
50
        }
51
52
        $this->from = clone $from;
53
        $this->to = clone $to;
54
55
        if ($this->allDay) {
56
            $this->from = clone $from;
57
            $this->to = clone $from;
58
        }
59
    }
60
61
    /**
62
     * @param string $title
63
     * @param \DateTime $from
64
     * @param \DateTime $to
65
     * @param bool $allDay
66
     *
67
     * @return static
68
     * @throws InvalidLink
69
     */
70
    public static function create(string $title, DateTime $from, DateTime $to, bool $allDay = false)
71
    {
72
        return new static($title, $from, $to, $allDay);
73
    }
74
75
    /**
76
     * @param string $description
77
     *
78
     * @return $this
79
     */
80
    public function description(string $description)
81
    {
82
        $this->description = $description;
83
84
        return $this;
85
    }
86
87
    /**
88
     * @param string $address
89
     *
90
     * @return $this
91
     */
92
    public function address(string $address)
93
    {
94
        $this->address = $address;
95
96
        return $this;
97
    }
98
99
    /**
100
     * @param array $emails
0 ignored issues
show
Bug introduced by
There is no parameter named $emails. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
101
     *
102
     * @return $this
103
     */
104
    public function attendees(string $attendees)
105
    {
106
        if (! is_array($attendees)) {
107
            $attendees = explode(',', $attendees);
108
        }
109
110
        $this->attendees = $attendees;
111
112
        return $this;
113
    }
114
115
    public function google(): string
116
    {
117
        return (new Google())->generate($this);
118
    }
119
120
    public function ics(): string
121
    {
122
        return (new Ics())->generate($this);
123
    }
124
125
    public function yahoo(): string
126
    {
127
        return (new Yahoo())->generate($this);
128
    }
129
130
    public function webOutlook(): string
131
    {
132
        return (new WebOutlook())->generate($this);
133
    }
134
135
    public function __get($property)
136
    {
137
        return $this->$property;
138
    }
139
}
140