Completed
Pull Request — master (#18)
by ARCANEDEV
02:59
created

Controller   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 81
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 73.32%

Importance

Changes 0
Metric Value
dl 0
loc 81
ccs 11
cts 15
cp 0.7332
rs 10
c 0
b 0
f 0
wmc 6
lcom 1
cbo 2

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A getData() 0 4 1
A setData() 0 11 3
A setCurrentPage() 0 4 1
1
<?php namespace Arcanedev\Support\Http;
2
3
use Arcanedev\Support\Traits\Abortable;
4
use Illuminate\Routing\Controller as IlluminateController;
5
6
/**
7
 * Class     Controller
8
 *
9
 * @package  Arcanedev\Support\Http
10
 * @author   ARCANEDEV <[email protected]>
11
 */
12
abstract class Controller extends IlluminateController
13
{
14
    /* -----------------------------------------------------------------
15
     |  Traits
16
     | -----------------------------------------------------------------
17
     */
18
19
    use Abortable;
20
21
    /* -----------------------------------------------------------------
22
     |  Properties
23
     | -----------------------------------------------------------------
24
     */
25
26
    /**
27
     * The view data.
28
     *
29
     * @var array
30
     */
31
    protected $data = [];
32
33
    /* -----------------------------------------------------------------
34
     |  Constructor
35
     | -----------------------------------------------------------------
36
     */
37
38
    /**
39
     * Controller constructor.
40
     */
41 12
    public function __construct()
42
    {
43 12
        $this->setCurrentPage();
44 12
    }
45
46
    /* -----------------------------------------------------------------
47
     |  Getters & Setters
48
     | -----------------------------------------------------------------
49
     */
50
51
    /**
52
     * Get data.
53
     *
54
     * @return array
55
     */
56
    protected function getData()
57
    {
58
        return $this->data;
59
    }
60
61
    /**
62
     * Set view data.
63
     *
64
     * @param  string|array  $name
65
     * @param  mixed         $value
66
     *
67
     * @return self
68
     */
69 12
    protected function setData($name, $value = null)
70
    {
71 12
        if (is_array($name)) {
72
            $this->data = array_merge($this->data, $name);
73
        }
74 12
        elseif (is_string($name)) {
75 12
            $this->data[$name] = $value;
76 4
        }
77
78 12
        return $this;
79
    }
80
81
    /**
82
     * Set the current page.
83
     *
84
     * @param  string  $page
85
     *
86
     * @return self
87
     */
88 12
    protected function setCurrentPage($page = '')
89
    {
90 12
        return $this->setData('current_page', $page);
91
    }
92
}
93