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 (#214)
by joseph
21:10
created

BusinessIdentifierCodeFakerData::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1.037

Importance

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