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.

Matcher   A
last analyzed

Complexity

Total Complexity 8

Size/Duplication

Total Lines 49
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 8
lcom 1
cbo 2
dl 0
loc 49
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
B match() 0 18 6
A supports() 0 4 1
1
<?php
2
3
/**
4
 * This file is a part of the Yoqut package.
5
 *
6
 * (c) Sukhrob Khakimov <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that is distributed with this source code.
10
 */
11
12
namespace Yoqut\Component\Sms\Gateway;
13
14
use Yoqut\Component\Sms\Model\SmsInterface;
15
use Yoqut\Component\Sms\Model\GatewayInterface;
16
use Yoqut\Component\Sms\Gateway\Exception\InvalidGatewayException;
17
18
/**
19
 * The default gateway matcher implementation
20
 *
21
 * @author Sukhrob Khakimov <[email protected]>
22
 */
23
class Matcher implements MatcherInterface
24
{
25
    /**
26
     * The available gateways
27
     *
28
     * @var array
29
     */
30
    protected $gateways;
31
32
    /**
33
     * Constructor
34
     *
35
     * @param GatewayInterface[] $gateways
36
     */
37
    public function __construct(array $gateways)
38
    {
39
        $this->gateways = $gateways;
40
    }
41
42
    /**
43
     * {@inheritDoc}
44
     */
45
    public function match(SmsInterface $sms)
46
    {
47
        foreach ($this->gateways as $gateway) {
48
            if (!$this->supports($gateway)) {
49
                throw new InvalidGatewayException();
50
            }
51
52
            foreach ($gateway->getPrefixCodes() as $prefixCode) {
53
                $recipient = $sms->getRecipient();
54
55
                if ($prefixCode != '' && strrpos($recipient, $prefixCode, -strlen($recipient)) !== false) {
56
                    return $gateway;
57
                }
58
            }
59
        }
60
61
        return null;
62
    }
63
64
    /**
65
     * {@inheritDoc}
66
     */
67
    public function supports(GatewayInterface $gateway)
68
    {
69
        return $gateway instanceof GatewayInterface;
70
    }
71
}
72