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   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Test Coverage

Coverage 60%

Importance

Changes 0
Metric Value
eloc 12
dl 0
loc 38
ccs 12
cts 20
cp 0.6
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 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