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

joindin / callingallpapers-cli / 19026439121

03 Nov 2025 06:59AM UTC coverage: 30.963% (+4.1%) from 26.892%
19026439121

push

github

heiglandreas
Only add cfp tags to toot when they exist

This makes sure that there is no single hash-sign in the toots when
there is no tag in the CFP

0 of 3 new or added lines in 1 file covered. (0.0%)

405 of 1308 relevant lines covered (30.96%)

0.6 hits per line

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

0.0
/src/Notification/MastodonNotifier.php
1
<?php
2
/**
3
 * Copyright (c) Andreas Heigl<andreas@heigl.org>
4
 * Permission is hereby granted, free of charge, to any person obtaining a copy
5
 * of this software and associated documentation files (the "Software"), to deal
6
 * in the Software without restriction, including without limitation the rights
7
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
 * copies of the Software, and to permit persons to whom the Software is
9
 * furnished to do so, subject to the following conditions:
10
 * The above copyright notice and this permission notice shall be included in
11
 * all copies or substantial portions of the Software.
12
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
13
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
14
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
15
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
16
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
17
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
18
 * THE SOFTWARE.
19
 *
20
 * @author    Andreas Heigl<andreas@heigl.org>
21
 * @copyright Andreas Heigl
22
 * @license   http://www.opensource.org/licenses/mit-license.php MIT-License
23
 * @since     22.09.2016
24
 * @link      http://github.com/heiglandreas/callingallpapers
25
 */
26

27
namespace Callingallpapers\Notification;
28

29
use Callingallpapers\Entity\Cfp;
30
use Colorfield\Mastodon\MastodonAPI;
31
use GuzzleHttp\Psr7\Request;
32
use function json_encode;
33

34
class MastodonNotifier implements NotificationInterface
35
{
36
    protected $client;
37

38
    public function __construct(MastodonAPI $client)
×
39
    {
40
        $this->client = $client;
×
41
    }
42

43
    public function notify(Cfp $cfp)
×
44
    {
45
        $name = $this->shortenName($cfp->conferenceName);
×
46
        $uri  = $this->shortenUri($cfp->uri);
×
NEW
47
        $tags = '';
×
NEW
48
        if ($cfp->tags !== []) {
×
NEW
49
            $tags = ' #' . implode(' #', $cfp->tags);
×
50
        }
51

52
        $notificationString = sprintf(
×
53
            <<<'NOTIFICATION'
×
54
            24 hours until the CfP for "%1$s" closes: %2$s
55

56
            #cfp #conference%3$s
57
            NOTIFICATION,
×
58
            $name,
×
59
            $uri,
×
60
            $tags
×
61
        );
×
62

63
        $this->client->post('/statuses', [
×
64
            'status' => $notificationString,
×
65
            'visibility' => 'public',
×
66
        ]);
×
67
    }
68

69
    protected function shortenName($name)
×
70
    {
71
        if (strlen($name) < 70) {
×
72
            return $name;
×
73
        }
74
        return substr($name, 0, 69) . '…';
×
75
    }
76

77
    protected function shortenUri($uri)
×
78
    {
79
        return $uri;
×
80
    }
81

82
    protected function formUrlEncode(array $stuff)
×
83
    {
84
        return http_build_query($stuff);
×
85
    }
86
}
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