Completed
Pull Request — master (#657)
by Guy
01:24
created

Match::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
namespace Mpociot\ApiDoc\Matching\RouteMatcher;
3
4
use Illuminate\Routing\Route;
5
6
class Match implements \ArrayAccess
7
{
8
    /**
9
     * @var Route
10
     */
11
    protected $route;
12
13
    /**
14
     * @var array
15
     */
16
    protected $rules;
17
18
    /**
19
     * Match constructor.
20
     * @param Route $route
21
     * @param array $applyRules
22
     */
23
    public function __construct(Route $route, array $applyRules)
24
    {
25
        $this->route = $route;
26
        $this->rules = $applyRules;
27
    }
28
29
    /**
30
     * @return Route
31
     */
32
    public function getRoute()
33
    {
34
        return $this->route;
35
    }
36
37
    /**
38
     * @return array
39
     */
40
    public function getRules()
41
    {
42
        return $this->rules;
43
    }
44
45
    /**
46
     * @inheritDoc
47
     */
48
    public function offsetExists($offset)
49
    {
50
        return is_callable([$this, 'get' . ucfirst($offset)]);
51
    }
52
53
    /**
54
     * @inheritDoc
55
     */
56
    public function offsetGet($offset)
57
    {
58
        return call_user_func([$this, 'get' . ucfirst($offset)]);
59
    }
60
61
    /**
62
     * @inheritDoc
63
     */
64
    public function offsetSet($offset, $value)
65
    {
66
        return $this->$offset = $value;
67
    }
68
69
    /**
70
     * @inheritDoc
71
     */
72
    public function offsetUnset($offset)
73
    {
74
        $this->$offset = null;
75
    }
76
}
77