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   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 41
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 17
c 1
b 0
f 0
dl 0
loc 41
rs 10
ccs 0
cts 19
cp 0
wmc 5

4 Methods

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