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.

All::getName()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
namespace Nubs\RandomNameGenerator;
3
4
use Cinam\Randomizer\Randomizer;
5
6
/**
7
 * A generator that uses all of the other generators randomly.
8
 */
9
class All extends AbstractGenerator implements Generator
10
{
11
    /** @type array The other generators to use. */
12
    protected $_generators;
13
14
    /** @type Cinam\Randomizer\Randomizer The random number generator. */
15
    protected $_randomizer;
16
17
    /**
18
     * Initializes the All Generator with the list of generators to choose from.
19
     *
20
     * @api
21
     * @param array $generators The random generators to use.
22
     * @param \Cinam\Randomizer\Randomizer $randomizer The random number generator.
23
     */
24
    public function __construct(array $generators, Randomizer $randomizer = null)
25
    {
26
        $this->_generators = $generators;
27
        $this->_randomizer = $randomizer;
28
    }
29
30
    /**
31
     * Constructs an All Generator using the default list of generators.
32
     *
33
     * @api
34
     * @param \Cinam\Randomizer\Randomizer $randomizer The random number generator.
35
     * @return \Nubs\RandomNameGenerator\All The constructed generator.
36
     */
37
    public static function create(Randomizer $randomizer = null)
38
    {
39
        return new self([new Alliteration($randomizer), new Vgng($randomizer)], $randomizer);
40
    }
41
42
    /**
43
     * Gets a randomly generated name using the configured generators.
44
     *
45
     * @api
46
     * @return string A random name.
47
     */
48
    public function getName()
49
    {
50
        return $this->_getRandomGenerator()->getName();
51
    }
52
53
    /**
54
     * Get a random generator from the list of generators.
55
     *
56
     * @return \Nubs\RandomNameGenerator\Generator A random generator.
57
     */
58
    protected function _getRandomGenerator()
59
    {
60
        return $this->_randomizer ? $this->_randomizer->getArrayValue($this->_generators) : $this->_generators[array_rand($this->_generators)];
61
    }
62
}
63