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   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 47
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 19
dl 0
loc 47
ccs 14
cts 14
cp 1
rs 10
c 0
b 0
f 0
wmc 6

5 Methods

Rating   Name   Duplication   Size   Complexity  
A getRegionAndBranch() 0 3 1
A getBank() 0 3 1
A getCountryCode() 0 9 2
A __construct() 0 3 1
A __invoke() 0 3 1
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