1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* Copyright (c) Andreas Heigl<[email protected] |
5
|
|
|
* |
6
|
|
|
* Licensed under the MIT License. See LICENSE.md file in the project root |
7
|
|
|
* for full license information. |
8
|
|
|
*/ |
9
|
|
|
|
10
|
|
|
namespace Callingallpapers\Parser\ConfsTech; |
11
|
|
|
|
12
|
|
|
use Callingallpapers\Entity\Cfp; |
13
|
|
|
use Callingallpapers\Service\GeolocationService; |
14
|
|
|
use Callingallpapers\Service\TimezoneService; |
15
|
|
|
use DateTimeImmutable; |
16
|
|
|
use DateTimeZone; |
17
|
|
|
|
18
|
|
|
class ConferenceParser |
19
|
|
|
{ |
20
|
|
|
private $geolocation; |
21
|
|
|
|
22
|
|
|
private $timezone; |
23
|
|
|
|
24
|
|
|
public function __construct( |
25
|
|
|
GeolocationService $geolocation, |
26
|
|
|
TimezoneService $timezone |
27
|
|
|
) { |
28
|
|
|
$this->geolocation = $geolocation; |
29
|
|
|
$this->timezone = $timezone; |
30
|
|
|
} |
31
|
|
|
|
32
|
|
|
public function __invoke(array $conference) : Cfp |
33
|
|
|
{ |
34
|
|
|
$cfp = new Cfp(); |
35
|
|
|
$cfp->location = $conference['city']; |
36
|
|
|
|
37
|
|
|
$geolocation = $this->geolocation->getLocationForAddress( |
38
|
|
|
$conference['country'] . ', ' . $cfp->location |
39
|
|
|
); |
40
|
|
|
|
41
|
|
|
$cfp->latitude = $geolocation->getLatitude(); |
42
|
|
|
$cfp->longitude = $geolocation->getLongitude(); |
43
|
|
|
|
44
|
|
|
$cfp->timezone = $this->timezone->getTimezoneForLocation( |
45
|
|
|
$cfp->latitude, |
46
|
|
|
$cfp->longitude |
47
|
|
|
); |
48
|
|
|
|
49
|
|
|
$cfp->conferenceName = $conference['name']; |
50
|
|
|
$cfp->eventStartDate = new DateTimeImmutable( |
51
|
|
|
$conference['startDate'] . ' 08:00:00', |
52
|
|
|
new DateTimeZone($cfp->timezone) |
53
|
|
|
); |
54
|
|
|
if (! isset($conference['endDate'])) { |
55
|
|
|
$conference['endDate'] = $conference['startDate']; |
56
|
|
|
} |
57
|
|
|
$cfp->eventEndDate = new DateTimeImmutable( |
58
|
|
|
$conference['endDate'] . ' 17:00:00', |
59
|
|
|
new DateTimeZone($cfp->timezone) |
60
|
|
|
); |
61
|
|
|
|
62
|
|
|
$cfp->dateEnd = new DateTimeImmutable( |
63
|
|
|
$conference['cfpEndDate'] . ' 23:59:59', |
64
|
|
|
new DateTimeZone($cfp->timezone) |
65
|
|
|
); |
66
|
|
|
|
67
|
|
|
$cfp->conferenceUri = $conference['url']; |
68
|
|
|
$cfp->uri = $conference['url']; |
69
|
|
|
if (isset($conference['cfpUrl'])) { |
70
|
|
|
$cfp->uri = $conference['cfpUrl']; |
71
|
|
|
} |
72
|
|
|
|
73
|
|
|
return $cfp; |
74
|
|
|
} |
75
|
|
|
} |
76
|
|
|
|