Completed
Push — master ( fe2892...6427ed )
by Oleg
03:03
created

ChangeAttribute   A

Complexity

Total Complexity 29

Size/Duplication

Total Lines 177
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 95.77%

Importance

Changes 0
Metric Value
dl 0
loc 177
ccs 68
cts 71
cp 0.9577
rs 10
c 0
b 0
f 0
wmc 29
lcom 1
cbo 1

18 Methods

Rating   Name   Duplication   Size   Complexity  
B __construct() 0 17 10
A toArray() 0 22 3
A getClass() 0 4 1
A setClass() 0 4 1
A getHide() 0 4 1
A setHide() 0 4 1
A getHref() 0 4 1
A setHref() 0 4 1
A getHtml() 0 4 1
A setHtml() 0 4 1
A getRemove() 0 4 1
A setRemove() 0 4 1
A getSrc() 0 4 1
A setSrc() 0 4 1
A getStyle() 0 4 1
A setStyle() 0 4 1
A getText() 0 4 1
A setText() 0 4 1
1
<?php
2
/**
3
 * @author Oleg Krivtsov <[email protected]>
4
 * @date 04 May 2017
5
 * @copyright (c) 2017, Web Marketing ROI
6
 */
7
namespace WebMarketingROI\OptimizelyPHP\Resource\v2;
8
9
use WebMarketingROI\OptimizelyPHP\Exception;
10
11
/**
12
 * An Optimizely campaign change attributes.
13
 */
14
class ChangeAttribute
15
{
16
    /**
17
     * Name of the class to set the element(s) matched by a selector to
18
     * @var string
19
     */
20
    private $class;
21
    
22
    /**
23
     * Whether or not to hide the element(s) matched by a selector
24
     * @var boolean
25
     */
26
    private $hide;
27
    
28
    /**
29
     * Value of href attribute to add to element(s) matched by a selector
30
     * @var string
31
     */
32
    private $href;
33
    
34
    /**
35
     * Value of HTML attribute to add to element(s) matched by a selector
36
     * @var string
37
     */
38
    private $html;
39
    
40
    /**
41
     * Whether or not to remove the element(s) matched by a selector
42
     * @var boolean 
43
     */
44
    private $remove;
45
    
46
    /**
47
     * Value of src attribute to add to element(s) matched by a selector
48
     * @var string
49
     */
50
    private $src;
51
    
52
    /**
53
     * Value of style attribute to add to element(s) matched by a selector
54
     * @var string
55
     */
56
    private $style;
57
    
58
    /**
59
     * Value of text attribute to add to the element(s) matched by a selector
60
     * @var string
61
     */
62
    private $text;
63
    
64
    /**
65
     * Constructor.
66
     */
67 3
    public function __construct($options = array())
68
    {
69 3
        foreach ($options as $name=>$value) {
70
            switch ($name) {                
71 3
                case 'class': $this->setClass($value); break;
0 ignored issues
show
Coding Style introduced by
The case body in a switch statement must start on the line following the statement.

According to the PSR-2, the body of a case statement must start on the line immediately following the case statement.

switch ($expr) {
case "A":
    doSomething(); //right
    break;
case "B":

    doSomethingElse(); //wrong
    break;

}

To learn more about the PSR-2 coding standard, please refer to the PHP-Fig.

Loading history...
Coding Style introduced by
Terminating statement must be on a line by itself

As per the PSR-2 coding standard, the break (or other terminating) statement must be on a line of its own.

switch ($expr) {
     case "A":
         doSomething();
         break; //wrong
     case "B":
         doSomething();
         break; //right
     case "C:":
         doSomething();
         return true; //right
 }

To learn more about the PSR-2 coding standard, please refer to the PHP-Fig.

Loading history...
72 3
                case 'hide': $this->setHide($value); break;
0 ignored issues
show
Coding Style introduced by
The case body in a switch statement must start on the line following the statement.

According to the PSR-2, the body of a case statement must start on the line immediately following the case statement.

switch ($expr) {
case "A":
    doSomething(); //right
    break;
case "B":

    doSomethingElse(); //wrong
    break;

}

To learn more about the PSR-2 coding standard, please refer to the PHP-Fig.

Loading history...
Coding Style introduced by
Terminating statement must be on a line by itself

As per the PSR-2 coding standard, the break (or other terminating) statement must be on a line of its own.

switch ($expr) {
     case "A":
         doSomething();
         break; //wrong
     case "B":
         doSomething();
         break; //right
     case "C:":
         doSomething();
         return true; //right
 }

To learn more about the PSR-2 coding standard, please refer to the PHP-Fig.

Loading history...
73 3
                case 'href': $this->setHref($value); break;
0 ignored issues
show
Coding Style introduced by
The case body in a switch statement must start on the line following the statement.

According to the PSR-2, the body of a case statement must start on the line immediately following the case statement.

switch ($expr) {
case "A":
    doSomething(); //right
    break;
case "B":

    doSomethingElse(); //wrong
    break;

}

To learn more about the PSR-2 coding standard, please refer to the PHP-Fig.

Loading history...
Coding Style introduced by
Terminating statement must be on a line by itself

As per the PSR-2 coding standard, the break (or other terminating) statement must be on a line of its own.

switch ($expr) {
     case "A":
         doSomething();
         break; //wrong
     case "B":
         doSomething();
         break; //right
     case "C:":
         doSomething();
         return true; //right
 }

To learn more about the PSR-2 coding standard, please refer to the PHP-Fig.

Loading history...
74 3
                case 'html': $this->setHtml($value); break;
0 ignored issues
show
Coding Style introduced by
The case body in a switch statement must start on the line following the statement.

According to the PSR-2, the body of a case statement must start on the line immediately following the case statement.

switch ($expr) {
case "A":
    doSomething(); //right
    break;
case "B":

    doSomethingElse(); //wrong
    break;

}

To learn more about the PSR-2 coding standard, please refer to the PHP-Fig.

Loading history...
Coding Style introduced by
Terminating statement must be on a line by itself

As per the PSR-2 coding standard, the break (or other terminating) statement must be on a line of its own.

switch ($expr) {
     case "A":
         doSomething();
         break; //wrong
     case "B":
         doSomething();
         break; //right
     case "C:":
         doSomething();
         return true; //right
 }

To learn more about the PSR-2 coding standard, please refer to the PHP-Fig.

Loading history...
75 3
                case 'remove': $this->setRemove($value); break;
0 ignored issues
show
Coding Style introduced by
The case body in a switch statement must start on the line following the statement.

According to the PSR-2, the body of a case statement must start on the line immediately following the case statement.

switch ($expr) {
case "A":
    doSomething(); //right
    break;
case "B":

    doSomethingElse(); //wrong
    break;

}

To learn more about the PSR-2 coding standard, please refer to the PHP-Fig.

Loading history...
Coding Style introduced by
Terminating statement must be on a line by itself

As per the PSR-2 coding standard, the break (or other terminating) statement must be on a line of its own.

switch ($expr) {
     case "A":
         doSomething();
         break; //wrong
     case "B":
         doSomething();
         break; //right
     case "C:":
         doSomething();
         return true; //right
 }

To learn more about the PSR-2 coding standard, please refer to the PHP-Fig.

Loading history...
76 3
                case 'src': $this->setSrc($value); break;
0 ignored issues
show
Coding Style introduced by
The case body in a switch statement must start on the line following the statement.

According to the PSR-2, the body of a case statement must start on the line immediately following the case statement.

switch ($expr) {
case "A":
    doSomething(); //right
    break;
case "B":

    doSomethingElse(); //wrong
    break;

}

To learn more about the PSR-2 coding standard, please refer to the PHP-Fig.

Loading history...
Coding Style introduced by
Terminating statement must be on a line by itself

As per the PSR-2 coding standard, the break (or other terminating) statement must be on a line of its own.

switch ($expr) {
     case "A":
         doSomething();
         break; //wrong
     case "B":
         doSomething();
         break; //right
     case "C:":
         doSomething();
         return true; //right
 }

To learn more about the PSR-2 coding standard, please refer to the PHP-Fig.

Loading history...
77 3
                case 'style': $this->setStyle($value); break;
0 ignored issues
show
Coding Style introduced by
The case body in a switch statement must start on the line following the statement.

According to the PSR-2, the body of a case statement must start on the line immediately following the case statement.

switch ($expr) {
case "A":
    doSomething(); //right
    break;
case "B":

    doSomethingElse(); //wrong
    break;

}

To learn more about the PSR-2 coding standard, please refer to the PHP-Fig.

Loading history...
Coding Style introduced by
Terminating statement must be on a line by itself

As per the PSR-2 coding standard, the break (or other terminating) statement must be on a line of its own.

switch ($expr) {
     case "A":
         doSomething();
         break; //wrong
     case "B":
         doSomething();
         break; //right
     case "C:":
         doSomething();
         return true; //right
 }

To learn more about the PSR-2 coding standard, please refer to the PHP-Fig.

Loading history...
78 3
                case 'text': $this->setText($value); break;
0 ignored issues
show
Coding Style introduced by
The case body in a switch statement must start on the line following the statement.

According to the PSR-2, the body of a case statement must start on the line immediately following the case statement.

switch ($expr) {
case "A":
    doSomething(); //right
    break;
case "B":

    doSomethingElse(); //wrong
    break;

}

To learn more about the PSR-2 coding standard, please refer to the PHP-Fig.

Loading history...
Coding Style introduced by
Terminating statement must be on a line by itself

As per the PSR-2 coding standard, the break (or other terminating) statement must be on a line of its own.

switch ($expr) {
     case "A":
         doSomething();
         break; //wrong
     case "B":
         doSomething();
         break; //right
     case "C:":
         doSomething();
         return true; //right
 }

To learn more about the PSR-2 coding standard, please refer to the PHP-Fig.

Loading history...
79
                default:
80
                    throw new Exception('Unknown option found in the ChangeAttribute entity: ' . $name);
81
            }
82 3
        }
83 3
    }
84
    
85
    /**
86
     * Returns this object as array.
87
     */
88 1
    public function toArray()
89
    {
90
        $options = array(
91 1
            'class' => $this->getClass(),
92 1
            'hide' => $this->getHide(),
93 1
            'href' => $this->getHref(),
94 1
            'html' => $this->getHtml(),
95 1
            'remove' => $this->getRemove(),
96 1
            'src' => $this->getSrc(),
97 1
            'style' => $this->getStyle(),
98 1
            'text' => $this->getText(),
99 1
        );
100
        
101
        // Remove options with empty values
102 1
        $cleanedOptions = array();
103 1
        foreach ($options as $name=>$value) {
104 1
            if ($value!==null)
105 1
                $cleanedOptions[$name] = $value;
106 1
        }
107
        
108 1
        return $cleanedOptions;
109
    }
110
    
111 2
    public function getClass()
112
    {
113 2
        return $this->class;
114
    }
115
    
116 3
    public function setClass($class)
117
    {
118 3
        $this->class = $class;
119 3
    }
120
    
121 2
    public function getHide()
122
    {
123 2
        return $this->hide;
124
    }
125
    
126 3
    public function setHide($hide)
127
    {
128 3
        $this->hide = $hide;
129 3
    }
130
    
131 1
    public function getHref()
132
    {
133 1
        return $this->href;
134
    }
135
    
136 3
    public function setHref($href)
137
    {
138 3
        $this->href = $href;
139 3
    }
140
    
141 1
    public function getHtml()
142
    {
143 1
        return $this->html;
144
    }
145
    
146 3
    public function setHtml($html)
147
    {
148 3
        $this->html = $html;
149 3
    }
150
    
151 1
    public function getRemove()
152
    {
153 1
        return $this->remove;
154
    }
155
    
156 3
    public function setRemove($remove)
157
    {
158 3
        $this->remove = $remove;
159 3
    }
160
    
161 1
    public function getSrc()
162
    {
163 1
        return $this->src;
164
    }
165
    
166 3
    public function setSrc($src)
167
    {
168 3
        $this->src = $src;
169 3
    }
170
    
171 1
    public function getStyle()
172
    {
173 1
        return $this->style;
174
    }
175
    
176 3
    public function setStyle($style)
177
    {
178 3
        $this->style = $style;
179 3
    }
180
    
181 1
    public function getText()
182
    {
183 1
        return $this->text;
184
    }
185
    
186 3
    public function setText($text)
187
    {
188 3
        $this->text = $text;
189 3
    }
190
}
191
192
193
194
195
196