|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Acquia\LiftClient\Entity; |
|
4
|
|
|
|
|
5
|
|
|
use Acquia\LiftClient\Exception\LiftSdkException; |
|
6
|
|
|
|
|
7
|
|
|
class Probability extends Entity |
|
8
|
|
|
{ |
|
9
|
|
|
/** |
|
10
|
|
|
* @param array $array |
|
11
|
|
|
*/ |
|
12
|
63 |
|
public function __construct(array $array = []) |
|
13
|
|
|
{ |
|
14
|
63 |
|
parent::__construct($array); |
|
15
|
63 |
|
} |
|
16
|
|
|
|
|
17
|
|
|
/** |
|
18
|
|
|
* Sets the 'id' parameter. |
|
19
|
|
|
* |
|
20
|
|
|
* @param string $contentId |
|
21
|
|
|
* |
|
22
|
|
|
* @throws \Acquia\LiftClient\Exception\LiftSdkException |
|
23
|
|
|
* |
|
24
|
|
|
* @return \Acquia\LiftClient\Entity\Probability |
|
25
|
|
|
*/ |
|
26
|
39 |
View Code Duplication |
public function setContentId($contentId) |
|
27
|
|
|
{ |
|
28
|
39 |
|
if (!is_string($contentId)) { |
|
29
|
3 |
|
throw new LiftSdkException('Argument must be an instance of string.'); |
|
30
|
|
|
} |
|
31
|
36 |
|
$this['id'] = $contentId; |
|
32
|
|
|
|
|
33
|
36 |
|
return $this; |
|
34
|
|
|
} |
|
35
|
|
|
|
|
36
|
|
|
/** |
|
37
|
|
|
* Gets the 'id' parameter. |
|
38
|
|
|
* |
|
39
|
|
|
* @return string The Identifier of the Content Identifier |
|
40
|
|
|
*/ |
|
41
|
18 |
|
public function getContentId() |
|
42
|
|
|
{ |
|
43
|
18 |
|
return $this->getEntityValue('id', ''); |
|
44
|
|
|
} |
|
45
|
|
|
|
|
46
|
|
|
/** |
|
47
|
|
|
* @param string $contentConnectorId |
|
48
|
|
|
* |
|
49
|
|
|
* @throws \Acquia\LiftClient\Exception\LiftSdkException |
|
50
|
|
|
* |
|
51
|
|
|
* @return \Acquia\LiftClient\Entity\Probability |
|
52
|
|
|
*/ |
|
53
|
33 |
View Code Duplication |
public function setContentConnectorId($contentConnectorId = 'content_hub') |
|
54
|
|
|
{ |
|
55
|
33 |
|
if (!is_string($contentConnectorId)) { |
|
56
|
3 |
|
throw new LiftSdkException('Argument must be an instance of string.'); |
|
57
|
|
|
} |
|
58
|
30 |
|
$this['content_connector_id'] = $contentConnectorId; |
|
59
|
|
|
|
|
60
|
30 |
|
return $this; |
|
61
|
|
|
} |
|
62
|
|
|
|
|
63
|
|
|
/** |
|
64
|
|
|
* Gets the 'content_connector_id' parameter. |
|
65
|
|
|
* |
|
66
|
|
|
* @return string |
|
67
|
|
|
*/ |
|
68
|
12 |
|
public function getContentConnectorId() |
|
69
|
|
|
{ |
|
70
|
12 |
|
return $this->getEntityValue('content_connector_id', 'content_hub'); |
|
71
|
|
|
} |
|
72
|
|
|
|
|
73
|
|
|
/** |
|
74
|
|
|
* Sets the 'content_view_id' parameter. |
|
75
|
|
|
* |
|
76
|
|
|
* @param string $contentViewId |
|
77
|
|
|
* |
|
78
|
|
|
* @throws \Acquia\LiftClient\Exception\LiftSdkException |
|
79
|
|
|
* |
|
80
|
|
|
* @return \Acquia\LiftClient\Entity\Probability |
|
81
|
|
|
*/ |
|
82
|
39 |
|
public function setContentViewId($contentViewId) |
|
83
|
|
|
{ |
|
84
|
39 |
|
if (!is_string($contentViewId)) { |
|
85
|
3 |
|
throw new LiftSdkException('Argument must be an instance of string.'); |
|
86
|
|
|
} |
|
87
|
36 |
|
$this['content_view_id'] = $contentViewId; |
|
88
|
|
|
|
|
89
|
36 |
|
return $this; |
|
90
|
|
|
} |
|
91
|
|
|
|
|
92
|
|
|
/** |
|
93
|
|
|
* Gets the 'content_view_id' parameter. |
|
94
|
|
|
* |
|
95
|
|
|
* @return string The Content View Mode Identifier |
|
96
|
|
|
*/ |
|
97
|
18 |
|
public function getContentViewId() |
|
98
|
|
|
{ |
|
99
|
18 |
|
return $this->getEntityValue('content_view_id', ''); |
|
100
|
|
|
} |
|
101
|
|
|
|
|
102
|
|
|
/** |
|
103
|
|
|
* Sets the 'fraction' parameter. |
|
104
|
|
|
* |
|
105
|
|
|
* @param int|float $fraction |
|
106
|
|
|
* |
|
107
|
|
|
* @throws \Acquia\LiftClient\Exception\LiftSdkException |
|
108
|
|
|
* |
|
109
|
|
|
* @return \Acquia\LiftClient\Entity\Probability |
|
110
|
|
|
*/ |
|
111
|
45 |
|
public function setFraction($fraction) |
|
112
|
|
|
{ |
|
113
|
45 |
|
if (!is_numeric($fraction)) { |
|
114
|
3 |
|
throw new LiftSdkException('Argument must be an instance of any numeric type (int|float).'); |
|
115
|
|
|
} |
|
116
|
42 |
|
if ($fraction > 1 || $fraction < 0) { |
|
117
|
6 |
|
throw new LiftSdkException('Argument must be between 0 and 1 or those values themselves.'); |
|
118
|
|
|
} |
|
119
|
36 |
|
$this['fraction'] = $fraction; |
|
120
|
|
|
|
|
121
|
36 |
|
return $this; |
|
122
|
|
|
} |
|
123
|
|
|
|
|
124
|
|
|
/** |
|
125
|
|
|
* Gets the 'fraction' parameter. |
|
126
|
|
|
* |
|
127
|
|
|
* @return int|float The fraction |
|
128
|
|
|
*/ |
|
129
|
18 |
|
public function getFraction() |
|
130
|
|
|
{ |
|
131
|
18 |
|
return $this->getEntityValue('fraction', 0); |
|
132
|
|
|
} |
|
133
|
|
|
} |
|
134
|
|
|
|