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 (#65)
by
unknown
01:40
created

TypeContainer::add()   A

Complexity

Conditions 3
Paths 1

Size

Total Lines 19
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 19
rs 9.4285
c 0
b 0
f 0
cc 3
eloc 10
nc 1
nop 1
1
<?php
2
3
namespace Minime\Annotations;
4
5
/**
6
 * @property Types\IntegerType $integerType
7
 * @property Types\StringType $stringType
8
 * @property Types\FloatType $floatType
9
 * @property Types\JsonType $jsonType
10
 * @property Types\ConcreteType $concreteType
11
 */
12
class TypeContainer
13
{
14
    /**
15
     * Stores the lambda functions for each type.
16
     *
17
     * @var array
18
     */
19
    private $builders;
20
21
    /**
22
     * Stores built types.
23
     *
24
     * @var array
25
     */
26
    private $types;
27
28
    /**
29
     * Add a lambda function.
30
     *
31
     * @param string $name
32
     */
33
    public function add($name)
34
    {
35
        $this->builders[$name] = function() use($name) {
36
            $type = 'Minime\\Annotations\\Types\\' . ucfirst($name);
37
38
            // do we have in default configuration setup?
39
            if (!class_exists($type)) {
40
                $type = $name;
41
            }
42
43
            if (is_callable($type . '::getType')) {
44
                $typeClass = call_user_func($type . '::getType');
45
            } else {
46
                $typeClass = new $type;
47
            }
48
49
            return new $typeClass;
50
        };
51
    }
52
53
    /**
54
     * Remove a lambda function.
55
     *
56
     * @param string $name
57
     */
58
    public function remove($name)
59
    {
60
        unset($this->builders[$name]);
61
        unset($this->types[$name]);
62
    }
63
64
    /**
65
     * @param string $name
66
     *
67
     * @return TypeInterface
68
     */
69
    public function __get($name)
70
    {
71
        if (!isset($this->types[$name]) && isset($this->builders[$name])) {
72
            $this->types[$name] = $this->builders[$name]();
73
        }
74
75
        return $this->types[$name];
76
    }
77
}
78