Completed
Push — master ( cad668...977f99 )
by Andreas
10s
created

Cfp::addTag()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 6
rs 9.4285
cc 2
eloc 3
nc 2
nop 1
1
<?php
2
/**
3
 * Copyright (c) 2015-2016 Andreas Heigl<[email protected]>
4
 *
5
 * Permission is hereby granted, free of charge, to any person obtaining a copy
6
 * of this software and associated documentation files (the "Software"), to deal
7
 * in the Software without restriction, including without limitation the rights
8
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
 * copies of the Software, and to permit persons to whom the Software is
10
 * furnished to do so, subject to the following conditions:
11
 *
12
 * The above copyright notice and this permission notice shall be included in
13
 * all copies or substantial portions of the Software.
14
 *
15
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
 * THE SOFTWARE.
22
 *
23
 * @author    Andreas Heigl<[email protected]>
24
 * @copyright 2015-2016 Andreas Heigl/callingallpapers.com
25
 * @license   http://www.opensource.org/licenses/mit-license.php MIT-License
26
 * @version   0.0
27
 * @since     01.12.2015
28
 * @link      http://github.com/heiglandreas/callingallpapers-cli
29
 */
30
namespace Callingallpapers\Entity;
31
32
class Cfp
33
{
34
    /** @var string  */
35
    public $conferenceName = '';
36
37
    /** @var string  */
38
    public $conferenceUri = '';
39
40
    /** @var string  */
41
    public $uri = '';
42
43
    /** @var \DateTimeInterface */
44
    public $dateEnd;
45
46
    /** @var \DateTimeInterface  */
47
    public $dateStart;
48
49
    /** @var string  */
50
    public $description = '';
51
52
    /** @var array  */
53
    public $tags = array();
54
55
    /** @var string  */
56
    public $location = '';
57
58
    /** @var string */
59
    public $geolocation = '';
60
61
    /** @var \DateTimeInterface  */
62
    public $eventStartDate;
63
64
    /** @var \DateTimeInterface  */
65
    public $eventEndDate;
66
67
    /** @var float */
68
    public $latitude = 0.0;
69
70
    /** @var float  */
71
    public $longitude = 0.0;
72
73
    /** @var string  */
74
    public $timezone = 'UTC';
75
76
    /** @var string  */
77
    public $iconUri = '';
78
79
    public function __construct()
80
    {
81
        $this->dateStart      = new \DateTimeImmutable();
82
        $this->dateEnd        = new \DateTimeImmutable();
83
        $this->eventStartDate = new \DateTimeImmutable();
84
        $this->eventEndDate   = new \DateTimeImmutable();
85
    }
86
87
    public function toArray()
88
    {
89
        return array(
90
            'name'           => $this->conferenceName,
91
            'website_uri'    => $this->conferenceUri,
92
            'cfp_url'        => $this->uri,
93
            'cfp_start_date' => $this->dateStart->format('c'),
94
            'cfp_end_date'   => $this->dateEnd->format('c'),
95
            'description'    => $this->description,
96
            'tags'           => array_unique($this->tags),
97
            'start_date'     => $this->eventStartDate->format('c'),
98
            'end_date'       => $this->eventEndDate->format('c'),
99
            'location'       => $this->location,
100
            'latitude'       => (float) $this->latitude,
101
            'longitude'      => (float) $this->longitude,
102
            'timezone'       => $this->timezone,
103
        );
104
    }
105
106
    public function addTag($tag)
107
    {
108
        if (! in_array($tag, $this->tags)) {
109
            $this->tags[] = $tag;
110
        }
111
    }
112
}
113