Completed
Push — master ( 264ef8...b0b172 )
by Jared
01:34
created

Definition::propertyNames()   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 0
1
<?php
2
3
namespace Pulsar;
4
5
use ArrayAccess;
6
7
final class Definition implements ArrayAccess
8
{
9
    /** @var Property[] */
10
    private $properties;
11
12
    /**
13
     * @param Property[] $properties
14
     */
15
    public function __construct(array $properties)
16
    {
17
        $this->properties = $properties;
18
    }
19
20
    public function has(string $name): bool
21
    {
22
        return isset($this->properties[$name]);
23
    }
24
25
    public function get(string $name): ?Property
26
    {
27
        return $this->properties[$name] ?? null;
28
    }
29
30
    public function all(): array
31
    {
32
        return $this->properties;
33
    }
34
35
    public function offsetExists($offset)
36
    {
37
        return isset($this->properties[$offset]);
38
    }
39
40
    public function offsetGet($offset)
41
    {
42
        return $this->properties[$offset] ?? null;
43
    }
44
45
    public function offsetSet($offset, $value)
46
    {
47
        throw new \RuntimeException('Modifying a model definition is not allowed.');
48
    }
49
50
    public function offsetUnset($offset)
51
    {
52
        throw new \RuntimeException('Modifying a model definition is not allowed.');
53
    }
54
}
55