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.

LocaleIdentifierFakerData::__invoke()   A
last analyzed

Complexity

Conditions 2
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 0
Metric Value
cc 2
eloc 4
nc 1
nop 0
dl 0
loc 7
ccs 0
cts 6
cp 0
crap 6
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace EdmondsCommerce\DoctrineStaticMeta\Entity\Fields\FakerData\String;
6
7
use EdmondsCommerce\DoctrineStaticMeta\Entity\Fields\FakerData\AbstractFakerDataProvider;
8
use Faker\Generator;
9
use Symfony\Component\Intl\Intl;
10
11
class LocaleIdentifierFakerData extends AbstractFakerDataProvider
12
{
13
14
    /**
15
     * @var string[]
16
     */
17
    private static $locales;
18
19
    /**
20
     * LocaleIdentifierFakerDataProvider constructor.
21
     *
22
     * @param Generator $generator
23
     * @SuppressWarnings(PHPMD.StaticAccess)
24
     */
25
    public function __construct(Generator $generator)
26
    {
27
        parent::__construct($generator);
28
        if (null === self::$locales) {
0 ignored issues
show
introduced by
The condition null === self::locales is always false.
Loading history...
29
            self::$locales = Intl::getLocaleBundle()->getLocaleNames();
30
        }
31
    }
32
33
    public function __invoke(): string
34
    {
35
        do {
36
            $value = $this->generator->locale;
37
        } while (false === $this->isValid($value));
38
39
        return $value;
40
    }
41
42
    private function isValid(string $value): bool
43
    {
44
        if (!isset(self::$locales[$value])) {
45
            return false;
46
        }
47
48
        return true;
49
    }
50
}
51