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
Pull Request — master (#154)
by joseph
36:20
created

BusinessIdentifierCodeFakerData::getCountryCode()   A

Complexity

Conditions 2
Paths 1

Size

Total Lines 9
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 2

Importance

Changes 0
Metric Value
cc 2
eloc 5
nc 1
nop 0
dl 0
loc 9
ccs 5
cts 5
cp 1
crap 2
rs 10
c 0
b 0
f 0
1
<?php declare(strict_types=1);
2
3
namespace EdmondsCommerce\DoctrineStaticMeta\Entity\Fields\FakerData\String;
4
5
use EdmondsCommerce\DoctrineStaticMeta\Entity\Fields\FakerData\AbstractFakerDataProvider;
6
use Faker\Generator;
7
8
class BusinessIdentifierCodeFakerData extends AbstractFakerDataProvider
9
{
10
    /**
11
     * @see https://github.com/symfony/symfony/issues/18263
12
     * @see \Symfony\Component\Intl\Data\Generator\RegionDataGenerator
13
     */
14
    public const EXCLUDED_CODES = [
15
        'ZZ',
16
        'BV',
17
        'QO',
18
        'EU',
19
        'AN',
20
        'BV',
21
        'HM',
22
        'CP',
23
    ];
24
25 4
    public function __construct(Generator $generator)
26
    {
27 4
        parent::__construct($generator);
28 4
    }
29
30
31 4
    public function __invoke(): string
32
    {
33 4
        return $this->getBank() . $this->getCountryCode() . $this->getRegionAndBranch();
34
    }
35
36 4
    private function getBank(): string
37
    {
38 4
        return $this->generator->regexify('[A-Z]{4}');
39
    }
40
41 4
    private function getCountryCode(): string
42
    {
43
        //to prevent issues when using as an archetype, otherwise this gets replaced with the new field property name
44 4
        $property = 'country' . 'Code';
45
        do {
46 4
            $code = $this->generator->$property;
47 4
        } while (\in_array($code, self::EXCLUDED_CODES, true));
48
49 4
        return $code;
50
    }
51
52 4
    private function getRegionAndBranch(): string
53
    {
54 4
        return $this->generator->regexify('^([0-9A-Z]){2}([0-9A-Z]{3})?$');
55
    }
56
}
57