Completed
Push — master ( 450182...477b17 )
by Jared
01:31
created

Definition::offsetGet()   A

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 1
1
<?php
2
3
namespace Pulsar;
4
5
use ArrayAccess;
6
7
class Definition implements ArrayAccess
8
{
9
    /** @var self[] */
10
    private static $cache;
11
12
    /** @var Property[] */
13
    private $properties;
14
15
    /**
16
     * @param Property[] $properties
17
     */
18
    public function __construct(array $properties)
19
    {
20
        $this->properties = $properties;
21
    }
22
23
    public function has(string $name): bool
24
    {
25
        return isset($this->properties[$name]);
26
    }
27
28
    public function get(string $name): ?Property
29
    {
30
        return $this->properties[$name] ?? null;
31
    }
32
33
    public function all(): array
34
    {
35
        return $this->properties;
36
    }
37
38
    public function propertyNames(): array
39
    {
40
        return array_keys($this->properties);
41
    }
42
43
    public static function make(string $modelClass): self
0 ignored issues
show
Unused Code introduced by
The parameter $modelClass is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
44
    {
45
        // TODO
46
    }
47
48
    public function offsetExists($offset)
49
    {
50
        return isset($this->properties[$offset]);
51
    }
52
53
    public function offsetGet($offset)
54
    {
55
        return $this->properties[$offset] ?? null;
56
    }
57
58
    public function offsetSet($offset, $value)
59
    {
60
        throw new \RuntimeException('Modifying a model definition is not allowed.');
61
    }
62
63
    public function offsetUnset($offset)
64
    {
65
        throw new \RuntimeException('Modifying a model definition is not allowed.');
66
    }
67
}
68