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 (#225)
by joseph
18:50
created

UnicodeLanguageIdentifierFakerData   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 12
c 1
b 0
f 0
dl 0
loc 38
ccs 0
cts 21
cp 0
rs 10
wmc 6

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __invoke() 0 7 2
A __construct() 0 4 1
A getLanguages() 0 11 3
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 RuntimeException;
10
use Symfony\Component\Intl\Intl;
11
use Symfony\Component\Intl\Languages;
12
use function class_exists;
13
14
class UnicodeLanguageIdentifierFakerData extends AbstractFakerDataProvider
15
{
16
    /**
17
     * @var array
18
     */
19
    private $languages;
20
21
    public function __construct(Generator $generator)
22
    {
23
        parent::__construct($generator);
24
        $this->languages = $this->getLanguages();
25
    }
26
27
    public function __invoke()
28
    {
29
        do {
30
            $language = $this->generator->languageCode;
31
        } while (!isset($this->languages[$language]));
32
33
        return $language;
34
    }
35
36
    /**
37
     * Using the updated language provider if it exists
38
     *
39
     * @return array
40
     */
41
    private function getLanguages(): array
42
    {
43
        if (class_exists(Languages::class)) {
44
            return Languages::getNames();
45
        }
46
47
        if (class_exists(Intl::class)) {
48
            return Intl::getLanguageBundle()->getLanguageNames();
0 ignored issues
show
Deprecated Code introduced by
The function Symfony\Component\Intl\Intl::getLanguageBundle() has been deprecated: since Symfony 4.3, to be removed in 5.0. Use {@see Languages} or {@see Scripts} instead. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

48
            return /** @scrutinizer ignore-deprecated */ Intl::getLanguageBundle()->getLanguageNames();

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
49
        }
50
51
        throw new RuntimeException('No language provider exists');
52
    }
53
}
54