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 (#923)
by lee
03:57
created

AbstractLocaleWrapper   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Test Coverage

Coverage 62.5%

Importance

Changes 0
Metric Value
wmc 2
dl 0
loc 32
ccs 5
cts 8
cp 0.625
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 Respect\Validation\Exceptions\ComponentException;
17
use function class_exists;
18
use function mb_strtolower;
19
use function sprintf;
20
use function ucfirst;
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 1
    public function __construct(string $countryCode)
42
    {
43 1
        $normalized = ucfirst(mb_strtolower($countryCode));
44 1
        $className = sprintf('%s\\Locale\\%s%s', __NAMESPACE__, $normalized, $this->getSuffix());
45 1
        if (!class_exists($className)) {
46 1
            throw new ComponentException(sprintf('"%s" is not a supported country code', $countryCode));
47
        }
48
49
        $this->countryCode = $countryCode;
50
        parent::__construct(new $className());
51
    }
52
53
    /**
54
     * Returns the class name based on the identifier.
55
     *
56
     * @return string
57
     */
58
    abstract protected function getSuffix(): string;
59
}
60