Passed
Push — feature/packages ( 3445e7...793294 )
by Thierry
03:04
created

Store::jsonSerialize()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 0
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
<?php
2
0 ignored issues
show
Coding Style introduced by
Missing file doc comment
Loading history...
3
namespace Jaxon\Utils\View;
4
5
use Jaxon\Contracts\View as ViewContract;
6
use JsonSerializable;
7
8
class Store
0 ignored issues
show
Coding Style introduced by
Missing doc comment for class Store
Loading history...
9
{
10
    /**
11
     * The view renderer
12
     *
13
     * @var ViewContract
14
     */
15
    protected $xRenderer;
0 ignored issues
show
Coding Style introduced by
Expected 1 blank line(s) before first member var; 0 found
Loading history...
16
17
    /**
18
     * The view namespace
19
     *
20
     * @var string
21
     */
22
    protected $sNamespace;
23
24
    /**
25
     * The view name
26
     *
27
     * @var string
28
     */
29
    protected $sViewName;
30
31
    /**
32
     * The view data
33
     *
34
     * @var array
35
     */
36
    protected $aViewData = [];
37
38
    /**
39
     * Make a piece of data available for the rendered view
40
     *
41
     * @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...
42
     * @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...
43
     *
44
     * @return Store
45
     */
46
    public function with($name, $value)
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines before function; 1 found
Loading history...
47
    {
48
        $this->aViewData[$name] = $value;
49
        return $this;
50
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
51
52
    /**
53
     * Set the view to be rendered, with optional data
54
     *
55
     * @param ViewContract  $xRenderer        The view renderer
0 ignored issues
show
Coding Style introduced by
Expected 1 spaces after parameter type; 2 found
Loading history...
Coding Style introduced by
Expected 2 spaces after parameter name; 8 found
Loading history...
56
     * @param string        $sNamespace       The view namespace
0 ignored issues
show
Coding Style introduced by
Expected 7 spaces after parameter type; 8 found
Loading history...
Coding Style introduced by
Expected 1 spaces after parameter name; 7 found
Loading history...
57
     * @param string        $sViewName        The view name
0 ignored issues
show
Coding Style introduced by
Expected 7 spaces after parameter type; 8 found
Loading history...
Coding Style introduced by
Expected 2 spaces after parameter name; 8 found
Loading history...
58
     * @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...
59
     *
60
     * @return void
61
     */
62
    public function setView(ViewContract $xRenderer, $sNamespace, $sViewName, array $aViewData = [])
63
    {
64
        $this->xRenderer = $xRenderer;
1 ignored issue
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 2 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
65
        $this->sNamespace = trim($sNamespace);
66
        $this->sViewName = trim($sViewName);
1 ignored issue
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 2 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
67
        $this->aViewData = array_merge($this->aViewData, $aViewData);
1 ignored issue
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 2 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
68
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
69
70
    /**
71
     * Get the view namespace
72
     *
73
     * @return string        The view namespace
74
     */
75
    public function getNamespace()
76
    {
77
        return $this->sNamespace;
78
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
79
80
    /**
81
     * Get the view name
82
     *
83
     * @return string        The view name
84
     */
85
    public function getViewName()
86
    {
87
        return $this->sViewName;
88
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
89
90
    /**
91
     * Get the view data
92
     *
93
     * @return array         The view data
94
     */
95
    public function getViewData()
96
    {
97
        return $this->aViewData;
98
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
99
100
    /**
101
     * Render a view using third party view system
102
     *
103
     * @return string        The string representation of the view
104
     */
105
    public function __toString()
106
    {
107
        return ($this->xRenderer) ? $this->xRenderer->render($this) : '';
108
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
109
110
    /**
111
     * Convert this object to string for json.
112
     *
113
     * This is a method of the JsonSerializable interface.
114
     *
115
     * @return string
116
     */
117
    public function jsonSerialize()
118
    {
119
        return $this->__toString();
120
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 0 found
Loading history...
121
}
122