1 | <?php |
||
14 | class VariationReach |
||
15 | { |
||
16 | /** |
||
17 | * Total number of visitors exposed to this particular variation |
||
18 | * @var integer |
||
19 | */ |
||
20 | private $count; |
||
21 | |||
22 | /** |
||
23 | * The name of the variation |
||
24 | * @var string |
||
25 | */ |
||
26 | private $name; |
||
27 | |||
28 | /** |
||
29 | * The unique identifier for the variation |
||
30 | * @var string |
||
31 | */ |
||
32 | private $variationId; |
||
33 | |||
34 | /** |
||
35 | * |
||
36 | * @var number |
||
37 | */ |
||
38 | private $variationReach; |
||
39 | |||
40 | /** |
||
41 | * Constructor. |
||
42 | */ |
||
43 | 3 | public function __construct($options = array()) |
|
44 | { |
||
45 | 3 | foreach ($options as $name=>$value) { |
|
46 | switch ($name) { |
||
47 | 3 | case 'count': $this->setCount($value); break; |
|
48 | 3 | case 'name': $this->setName($value); break; |
|
49 | 3 | case 'variation_id': $this->setVariationId($value); break; |
|
50 | 3 | case 'variation_reach': $this->setVariationReach($value); break; |
|
51 | default: |
||
52 | 3 | throw new Exception('Unknown option found in VariationReach entity: ' . $name); |
|
53 | } |
||
54 | } |
||
55 | 3 | } |
|
56 | |||
57 | /** |
||
58 | * Returns this object as array. |
||
59 | */ |
||
60 | 1 | public function toArray() |
|
61 | { |
||
62 | $options = array( |
||
63 | 1 | 'count' => $this->getCount(), |
|
64 | 1 | 'name' => $this->getName(), |
|
65 | 1 | 'variation_id' => $this->getVariationId(), |
|
66 | 1 | 'variation_reach' => $this->getVariationReach(), |
|
67 | ); |
||
68 | |||
69 | // Remove options with empty values |
||
70 | 1 | $cleanedOptions = array(); |
|
71 | 1 | foreach ($options as $name=>$value) { |
|
72 | 1 | if ($value!==null) |
|
73 | 1 | $cleanedOptions[$name] = $value; |
|
74 | } |
||
75 | |||
76 | 1 | return $cleanedOptions; |
|
77 | } |
||
78 | |||
79 | 1 | public function getCount() |
|
83 | |||
84 | 3 | public function setCount($count) |
|
88 | |||
89 | 1 | public function getName() |
|
93 | |||
94 | 3 | public function setName($name) |
|
98 | |||
99 | 1 | public function getVariationId() |
|
103 | |||
104 | 3 | public function setVariationId($variationId) |
|
108 | |||
109 | 1 | public function getVariationReach() |
|
113 | |||
114 | 3 | public function setVariationReach($variationReach) |
|
118 | } |
||
119 | |||
120 | |||
130 |
According to the PSR-2, the body of a case statement must start on the line immediately following the case statement.
}
To learn more about the PSR-2 coding standard, please refer to the PHP-Fig.