1 | <?php |
||
16 | class Parser |
||
17 | { |
||
18 | /** |
||
19 | * @var array |
||
20 | */ |
||
21 | private $chain; |
||
22 | |||
23 | /** |
||
24 | * @var \Illuminate\Http\Request |
||
25 | */ |
||
26 | protected $request; |
||
27 | |||
28 | /** |
||
29 | * @param \Illuminate\Http\Request $request |
||
30 | * @param array $chain |
||
31 | */ |
||
32 | 18 | public function __construct(Request $request, array $chain = []) |
|
|
|||
33 | { |
||
34 | 18 | $this->request = $request; |
|
35 | 18 | $this->chain = $chain; |
|
36 | 18 | } |
|
37 | |||
38 | /** |
||
39 | * Get the parser chain |
||
40 | * |
||
41 | * @return array The chain of ParserContracts that the parser evaluates. |
||
42 | */ |
||
43 | 2 | public function getChain() |
|
47 | |||
48 | /** |
||
49 | * Set the order of the parser chain |
||
50 | * |
||
51 | * @param array $chain |
||
52 | */ |
||
53 | 16 | public function setChain(array $chain) |
|
59 | |||
60 | /** |
||
61 | * Alias for setting the order of the chain |
||
62 | * |
||
63 | * @param array $chain |
||
64 | */ |
||
65 | 14 | public function setChainOrder(array $chain) |
|
71 | |||
72 | /** |
||
73 | * Iterate throught the parsers and attempt to retrieve |
||
74 | * a value, otherwise return null |
||
75 | * |
||
76 | * @return string|null |
||
77 | */ |
||
78 | 16 | public function parseToken() |
|
90 | |||
91 | /** |
||
92 | * Check whether a token exists in the chain |
||
93 | * |
||
94 | * @return boolean |
||
95 | */ |
||
96 | 16 | public function hasToken() |
|
100 | |||
101 | /** |
||
102 | * Set the request instance. |
||
103 | * |
||
104 | * @param \Illuminate\Http\Request $request |
||
105 | * |
||
106 | * @return Parser |
||
107 | */ |
||
108 | 2 | public function setRequest(Request $request) |
|
114 | } |
||
115 |