• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

joindin / callingallpapers-cli / 19017699028

02 Nov 2025 08:25PM UTC coverage: 26.857% (-12.5%) from 39.394%
19017699028

push

github

heiglandreas
Move to coveralls action

405 of 1508 relevant lines covered (26.86%)

0.52 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/src/Reader/ApiCfpReader.php
1
<?php
2
/**
3
 * Copyright (c) 2015-2016 Andreas Heigl<andreas@heigl.org>
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<andreas@heigl.org>
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\Reader;
31

32
use Callingallpapers\Entity\Cfp;
33
use Callingallpapers\Entity\CfpList;
34
use DateInterval;
35
use DateTimeImmutable;
36
use DateTimeInterface;
37
use DateTimeZone;
38
use GuzzleHttp\Client;
39

40
class ApiCfpReader
41
{
42
    protected $baseUri;
43

44
    protected $bearerToken;
45

46
    protected $client;
47

48
    public function __construct($baseUri, $bearerToken, $client = null)
×
49
    {
50
        $this->baseUri = str_Replace('/cfp', '', $baseUri);
×
51

52
        $this->bearerToken = $bearerToken;
×
53
        if (null === $client) {
×
54
            $client = new Client([
×
55
                'headers' => [
×
56
                    'Accept' => 'application/json',
×
57
                ]
×
58
            ]);
×
59
        }
60
        $this->client = $client;
×
61
    }
62

63
    public function getCfpsEndingWithinInterval(DateInterval $interval, DateTimeInterface|null $date = null): CfpList
×
64
    {
65
        if (null === $date) {
×
66
            $date = new DateTimeImmutable();
×
67
        }
68

69
        $endDate = $date->add($interval);
×
70

71
        $list = new CfpList();
×
72

73
        try {
74
            $result = $this->client->get(sprintf(
×
75
                '%s/search?date_cfp_end[]=%s&date_cfp_end_compare[]=%s&date_cfp_end[]=%s&date_cfp_end_compare[]=%s',
×
76
                $this->baseUri,
×
77
                urlencode($date->setTimezone(new DateTimeZone('UTC'))->format('c')),
×
78
                urlencode('>'),
×
79
                urlencode($endDate->setTimezone(new DateTimeZone('UTC'))->format('c')),
×
80
                urlencode('<')
×
81
            ), [
×
82
                'headers' => [
×
83
                    'Accept' => 'application/json',
×
84
                ]
×
85
            ]);
×
86

87
            $items = \GuzzleHttp\json_decode($result->getBody()->getContents(), true);
×
88
        } catch (\Exception $e) {
×
89
            return $list;
×
90
        }
91

92
        if (! $items) {
×
93
            return $list;
×
94
        }
95

96
        foreach ($items['cfps'] as $item) {
×
97
            $cfp = new Cfp();
×
98
            $cfp->conferenceName = $item['name'];
×
99
            $cfp->conferenceUri  = $item['eventUri'];
×
100
            $cfp->dateEnd        = new DateTimeImmutable($item['dateCfpEnd']);
×
101
            $cfp->dateStart      = new DateTimeImmutable($item['dateCfpStart']);
×
102
            $cfp->eventEndDate   = new DateTimeImmutable($item['dateEventEnd']);
×
103
            $cfp->eventStartDate = new DateTimeImmutable($item['dateEventStart']);
×
104
            $cfp->description    = $item['description'];
×
105
            $cfp->location       = $item['location'];
×
106
            $cfp->latitude       = $item['latitude'];
×
107
            $cfp->longitude      = $item['longitude'];
×
108
            $cfp->iconUri        = $item['iconUri'];
×
109
            $cfp->uri            = $item['uri'];
×
110
            $cfp->tags           = array_filter($item['tags'], function ($item) {
×
111
                return (bool) $item;
×
112
            });
×
113
            $cfp->timezone       = $item['timezone'];
×
114

115
            $tz = new DateTimeZone($cfp->timezone);
×
116

117
            $cfp->dateEnd->setTimezone($tz);
×
118
            $cfp->dateStart->setTimezone($tz);
×
119
            $cfp->eventEndDate->setTimezone($tz);
×
120
            $cfp->eventStartDate->setTimezone($tz);
×
121

122
            $list->append($cfp);
×
123
        }
124

125
        return $list;
×
126
    }
127
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc