Passed
Push — master ( 548923...89935f )
by Thierry
08:39
created

Bag   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 75
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 7
eloc 11
c 1
b 0
f 0
dl 0
loc 75
rs 10

6 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A touched() 0 3 1
A getAll() 0 3 1
A set() 0 4 1
A setName() 0 4 1
A get() 0 3 2
1
<?php
2
0 ignored issues
show
Coding Style introduced by
Missing file doc comment
Loading history...
3
namespace Jaxon\Response\Plugin\DataBag;
4
5
use function is_array;
6
7
class Bag
0 ignored issues
show
Coding Style introduced by
Missing doc comment for class Bag
Loading history...
8
{
9
    /**
10
     * @var array
11
     */
12
    protected $aData = [];
0 ignored issues
show
Coding Style introduced by
Expected 1 blank line(s) before first member var; 0 found
Loading history...
13
14
    /**
15
     * @var string
16
     */
17
    protected $sName = '';
18
19
    /**
20
     * @var bool
0 ignored issues
show
Bug introduced by
Expected "boolean" but found "bool" for @var tag in member variable comment
Loading history...
21
     */
22
    protected $bTouched = false;
23
24
    /**
25
     * The constructor
26
     *
27
     * @param array $aData
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
28
     */
29
    public function __construct(array $aData)
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines before function; 1 found
Loading history...
30
    {
31
        $this->aData = $aData;
32
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
33
34
    /**
35
     * @return bool
36
     */
37
    public function touched()
38
    {
39
        return $this->bTouched;
40
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
41
42
    /**
43
     * @param string $sName
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
44
     *
45
     * @return Bag
46
     */
47
    public function setName($sName)
48
    {
49
        $this->sName = $sName;
50
        return $this;
51
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
52
53
    /**
54
     * @return array
55
     */
56
    public function getAll()
57
    {
58
        return $this->aData;
59
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
60
61
    /**
62
     * @param string $sKey
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
63
     * @param mixed $xValue
0 ignored issues
show
Coding Style introduced by
Expected 2 spaces after parameter type; 1 found
Loading history...
Coding Style introduced by
Missing parameter comment
Loading history...
64
     *
65
     * @return void
66
     */
67
    public function set($sKey, $xValue)
68
    {
69
        $this->bTouched = true;
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 19 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...
70
        $this->aData[$this->sName][$sKey] = $xValue;
71
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
72
73
    /**
74
     * @param string $sKey
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
75
     * @param mixed $xValue
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
Coding Style introduced by
Expected 2 spaces after parameter type; 1 found
Loading history...
76
     *
77
     * @return mixed
78
     */
79
    public function get($sKey, $xValue = null)
80
    {
81
        return isset($this->aData[$this->sName][$sKey]) ? $this->aData[$this->sName][$sKey] : $xValue;
82
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 0 found
Loading history...
83
}
84