GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Push — master ( 15375f...2893b6 )
by Alexander
02:22
created

getCredentialsTypeByService()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 12
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 12
rs 9.4285
cc 1
eloc 7
nc 1
nop 1
1
<?php
2
3
/*
4
 * (c) Alexander Zhukov <[email protected]>
5
 *
6
 * For the full copyright and license information, please view the LICENSE
7
 * file that was distributed with this source code.
8
 */
9
10
namespace Zbox\UnifiedPush\NotificationService;
11
12
use Zbox\UnifiedPush\Utils\ClientCredentials\CredentialsInterface;
13
use Zbox\UnifiedPush\Utils\ClientCredentials\DTO\AuthToken;
14
use Zbox\UnifiedPush\Utils\ClientCredentials\DTO\SSLCertificate;
15
use Zbox\UnifiedPush\Exception\DomainException;
16
17
/**
18
 * Class NotificationServices
19
 * @package Zbox\UnifiedPush\NotificationService
20
 */
21
class NotificationServices
22
{
23
    const APPLE_PUSH_NOTIFICATIONS_SERVICE     = 'APNS';
24
    const GOOGLE_CLOUD_MESSAGING               = 'GCM';
25
    const MICROSOFT_PUSH_NOTIFICATIONS_SERVICE = 'MPNS';
26
27
    /**
28
     * Checks if notification service is supported
29
     *
30
     * @param string $serviceName
31
     * @return string
32
     * @throws DomainException
33
     */
34
    public static function validateServiceName($serviceName)
35
    {
36
        if (!in_array($serviceName, array(
37
            self::APPLE_PUSH_NOTIFICATIONS_SERVICE,
38
            self::GOOGLE_CLOUD_MESSAGING,
39
            self::MICROSOFT_PUSH_NOTIFICATIONS_SERVICE,
40
        ))) {
41
            throw new DomainException(sprintf("Notification service '%s' is not supported.", $serviceName));
42
        }
43
        return $serviceName;
44
    }
45
46
    /**
47
     * @param string $serviceName
48
     * @return CredentialsInterface
49
     */
50
    public static function getCredentialsTypeByService($serviceName)
51
    {
52
        self::validateServiceName($serviceName);
53
54
        $credentials = array(
55
            self::APPLE_PUSH_NOTIFICATIONS_SERVICE      => new SSLCertificate(),
56
            self::GOOGLE_CLOUD_MESSAGING                => new AuthToken(),
57
            self::MICROSOFT_PUSH_NOTIFICATIONS_SERVICE  => new SSLCertificate()
58
        );
59
60
        return $credentials[$serviceName];
61
    }
62
}
63