Passed
Push — master ( 0602c9...8f96ba )
by Thierry
02:02
created

Store::jsonSerialize()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
0 ignored issues
show
Coding Style introduced by
Missing file doc comment
Loading history...
3
namespace Jaxon\Ui\View;
4
5
use Jaxon\Contracts\View as ViewContract;
6
7
class Store
0 ignored issues
show
Coding Style introduced by
Missing doc comment for class Store
Loading history...
8
{
9
    /**
10
     * The view renderer
11
     *
12
     * @var ViewContract
13
     */
14
    protected $xRenderer;
0 ignored issues
show
Coding Style introduced by
Expected 1 blank line(s) before first member var; 0 found
Loading history...
15
16
    /**
17
     * The view namespace
18
     *
19
     * @var string
20
     */
21
    protected $sNamespace;
22
23
    /**
24
     * The view name
25
     *
26
     * @var string
27
     */
28
    protected $sViewName;
29
30
    /**
31
     * The view data
32
     *
33
     * @var array
34
     */
35
    protected $aViewData = [];
36
37
    /**
38
     * Make a piece of data available for the rendered view
39
     *
40
     * @param string        $name            The data name
0 ignored issues
show
Coding Style introduced by
Expected 1 spaces after parameter type; 8 found
Loading history...
Coding Style introduced by
Expected 2 spaces after parameter name; 12 found
Loading history...
41
     * @param string        $value           The data value
0 ignored issues
show
Coding Style introduced by
Expected 1 spaces after parameter type; 8 found
Loading history...
Coding Style introduced by
Expected 1 spaces after parameter name; 11 found
Loading history...
42
     *
43
     * @return Store
44
     */
45
    public function with($name, $value)
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines before function; 1 found
Loading history...
46
    {
47
        $this->aViewData[$name] = $value;
48
        return $this;
49
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
50
51
    /**
52
     * Set the data to be rendered
53
     *
54
     * @param array         $aViewData        The view data
0 ignored issues
show
Coding Style introduced by
Expected 1 spaces after parameter type; 9 found
Loading history...
Coding Style introduced by
Expected 1 spaces after parameter name; 8 found
Loading history...
55
     *
56
     * @return void
57
     */
58
    public function setData(array $aViewData)
59
    {
60
        $this->aViewData = array_merge($this->aViewData, $aViewData);
61
        return $this;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this returns the type Jaxon\Ui\View\Store which is incompatible with the documented return type void.
Loading history...
62
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
63
64
    /**
65
     * Set the view to be rendered, with optional data
66
     *
67
     * @param ViewContract  $xRenderer        The view renderer
0 ignored issues
show
Coding Style introduced by
Expected 2 spaces after parameter name; 8 found
Loading history...
Coding Style introduced by
Expected 1 spaces after parameter type; 2 found
Loading history...
68
     * @param string        $sNamespace       The view namespace
0 ignored issues
show
Coding Style introduced by
Expected 1 spaces after parameter name; 7 found
Loading history...
Coding Style introduced by
Expected 7 spaces after parameter type; 8 found
Loading history...
69
     * @param string        $sViewName        The view name
0 ignored issues
show
Coding Style introduced by
Expected 2 spaces after parameter name; 8 found
Loading history...
Coding Style introduced by
Expected 7 spaces after parameter type; 8 found
Loading history...
70
     * @param array         $aViewData        The view data
0 ignored issues
show
Coding Style introduced by
Expected 8 spaces after parameter type; 9 found
Loading history...
Coding Style introduced by
Expected 2 spaces after parameter name; 8 found
Loading history...
71
     *
72
     * @return void
73
     */
74
    public function setView(ViewContract $xRenderer, $sNamespace, $sViewName, array $aViewData = [])
75
    {
76
        $this->xRenderer = $xRenderer;
77
        $this->sNamespace = trim($sNamespace);
78
        $this->sViewName = trim($sViewName);
79
        $this->aViewData = array_merge($this->aViewData, $aViewData);
80
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
81
82
    /**
83
     * Get the view namespace
84
     *
85
     * @return string        The view namespace
86
     */
87
    public function getNamespace()
88
    {
89
        return $this->sNamespace;
90
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
91
92
    /**
93
     * Get the view name
94
     *
95
     * @return string        The view name
96
     */
97
    public function getViewName()
98
    {
99
        return $this->sViewName;
100
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
101
102
    /**
103
     * Get the view data
104
     *
105
     * @return array         The view data
106
     */
107
    public function getViewData()
108
    {
109
        return $this->aViewData;
110
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
111
112
    /**
113
     * Render a view using third party view system
114
     *
115
     * @return string        The string representation of the view
116
     */
117
    public function __toString()
118
    {
119
        return ($this->xRenderer) ? $this->xRenderer->render($this) : '';
120
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
121
122
    /**
123
     * Convert this object to string for json.
124
     *
125
     * This is a method of the JsonSerializable interface.
126
     *
127
     * @return string
128
     */
129
    public function jsonSerialize()
130
    {
131
        return $this->__toString();
132
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 0 found
Loading history...
133
}
134