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.
Passed
Pull Request — master (#221)
by joseph
03:45
created

LocaleIdentifierFakerData::__construct()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 2.032

Importance

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