Scrutinizer GitHub App not installed

We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.

Install GitHub App

Completed
Pull Request — master (#911)
by Henrique
04:59 queued 02:34
created

AbstractLocaleWrapper   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Test Coverage

Coverage 87.5%

Importance

Changes 0
Metric Value
wmc 2
dl 0
loc 32
ccs 7
cts 8
cp 0.875
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 10 2
1
<?php
2
3
/*
4
 * This file is part of Respect/Validation.
5
 *
6
 * (c) Alexandre Gomes Gaigalas <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the "LICENSE.md"
9
 * file that was distributed with this source code.
10
 */
11
12
declare(strict_types=1);
13
14
namespace Respect\Validation\Rules;
15
16
use function class_exists;
17
use function mb_strtolower;
18
use function sprintf;
19
use function ucfirst;
20
use Respect\Validation\Exceptions\ComponentException;
21
22
/**
23
 * Abstract class to help creating rules based on location.
24
 *
25
 * @author Henrique Moody <[email protected]>
26
 */
27
abstract class AbstractLocaleWrapper extends AbstractWrapper
28
{
29
    /**
30
     * @var string
31
     */
32
    private $countryCode;
33
34
    /**
35
     * Initializes the rule.
36
     *
37
     * @param string $countryCode
38
     *
39
     * @throws ComponentException When country is not supported.
40
     */
41 10
    public function __construct(string $countryCode)
42
    {
43 10
        $normalized = ucfirst(mb_strtolower($countryCode));
44 10
        $className = sprintf('%s\\Locale\\%s%s', __NAMESPACE__, $normalized, $this->getSuffix());
45 10
        if (!class_exists($className)) {
46
            throw new ComponentException(sprintf('"%s" is not a supported country code', $countryCode));
47
        }
48
49 10
        $this->countryCode = $countryCode;
50 10
        parent::__construct(new $className);
51 10
    }
52
53
    /**
54
     * Returns the class name based on the identifier.
55
     *
56
     * @return string
57
     */
58
    abstract protected function getSuffix(): string;
59
}
60