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   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
eloc 12
dl 0
loc 38
ccs 0
cts 20
cp 0
rs 10
c 0
b 0
f 0
wmc 6

3 Methods

Rating   Name   Duplication   Size   Complexity  
A isValid() 0 7 2
A __invoke() 0 7 2
A __construct() 0 5 2
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