Completed
Push — master ( e311cb...18f318 )
by Jared
11:52
created

Error::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 6
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 3
1
<?php
2
3
namespace Pulsar;
4
5
use ArrayAccess;
6
7
class Error implements ArrayAccess
8
{
9
    /** @var string */
10
    private $error;
11
12
    /** @var string */
13
    private $message;
14
15
    /** @var array */
16
    private $context;
17
18
    public function __construct(string $error, array $context, string $message)
19
    {
20
        $this->error = $error;
21
        $this->context = $context;
22
        $this->message = $message;
23
    }
24
25
    public function __toString()
26
    {
27
        return $this->message;
28
    }
29
30
    public function getError(): string
31
    {
32
        return $this->error;
33
    }
34
35
    public function getContext(): array
36
    {
37
        return $this->context;
38
    }
39
40
    public function getMessage(): string
41
    {
42
        return $this->message;
43
    }
44
45
    public function offsetExists($offset)
46
    {
47
        return property_exists($this, $offset);
48
    }
49
50
    public function offsetGet($offset)
51
    {
52
        return $this->$offset;
53
    }
54
55
    public function offsetSet($offset, $value)
56
    {
57
        throw new \InvalidArgumentException('Modifying a validation error is not supported');
58
    }
59
60
    public function offsetUnset($offset)
61
    {
62
        throw new \InvalidArgumentException('Modifying a validation error is not supported');
63
    }
64
}
65