Completed
Push — master ( dd0453...7030c1 )
by Edgar
02:30
created

AbstractParser::handler()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
rs 10
cc 1
eloc 1
nc 1
nop 0
1
<?php
2
3
namespace Inbounder\Parsers;
4
5
use Illuminate\Http\Request;
6
use Illuminate\Contracts\Support\Arrayable;
7
use Inbounder\Parsers\Contracts\ParserInterface;
8
9
abstract class AbstractParser implements ParserInterface, Arrayable
10
{
11
    /**
12
     * Request
13
     */
14
    protected $request;
15
16
    /**
17
     * Attributes
18
     */
19
    protected $attributes;
20
21
    /**
22
     * 
23
     */
24
    public function __set($name, $value)
25
    {
26
        $this->attributes[$name] = $value;
27
    }
28
29
    /**
30
     * Getter
31
     */
32
    public function __get($name)
33
    {
34
        if (array_key_exists($name, $this->attributes))
35
            return $this->attributes[$name];
36
37
        return null;
38
    }
39
40
    /**
41
     * Parse the request and return itself
42
     * 
43
     * @return ParserInterface
44
     */
45
    public abstract function parse() : ParserInterface;
1 ignored issue
show
Bug introduced by
This code did not parse for me. Apparently, there is an error somewhere around this line:

Syntax error, unexpected ':', expecting ';' or '{'
Loading history...
Coding Style introduced by
The abstract declaration must precede the visibility declaration
Loading history...
46
47
    /**
48
     * Set the request that will be parsed
49
     * 
50
     * @param Request $request
51
     * @return Void
52
     */
53
    public function request(Request $request)
54
    {
55
        $this->request = $request;
56
    }
57
58
    /**
59
     * Retrieve an input from the request
60
     * 
61
     * @param String $name
62
     * @return Mixed
63
     */
64
    public function input($name)
65
    {
66
        return $this->request->input($name);
67
    }
68
69
    /**
70
     * Get the instance as an array.
71
     *
72
     * @return array
73
     */
74
    public function toArray()
75
    {
76
        return $this->attributes;
77
    }
78
}
79