Completed
Push — master ( 621ea2...dd23a3 )
by Nick
12s
created

Probability::setFraction()   A

Complexity

Conditions 4
Paths 3

Size

Total Lines 12
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 12
rs 9.2
c 0
b 0
f 0
cc 4
eloc 7
nc 3
nop 1
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
    public function __construct(array $array = [])
13
    {
14
        parent::__construct($array);
15
    }
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
    public function setContentId($contentId)
27
    {
28
        if (!is_string($contentId)) {
29
            throw new LiftSdkException('Argument must be an instance of string.');
30
        }
31
        $this['content_id'] = $contentId;
32
33
        return $this;
34
    }
35
36
    /**
37
     * Gets the 'id' parameter.
38
     *
39
     * @return string The Identifier of the Content Identifier
40
     */
41
    public function getContentId()
42
    {
43
        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 View Code Duplication
    public function setContentConnectorId($contentConnectorId = 'content_hub')
54
    {
55
        if (!is_string($contentConnectorId)) {
56
            throw new LiftSdkException('Argument must be an instance of string.');
57
        }
58
        $this['content_connector_id'] = $contentConnectorId;
59
60
        return $this;
61
    }
62
63
    /**
64
     * Gets the 'content_connector_id' parameter.
65
     *
66
     * @return string
67
     */
68
    public function getContentConnectorId()
69
    {
70
        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
    public function setContentViewId($contentViewId)
83
    {
84
        if (!is_string($contentViewId)) {
85
            throw new LiftSdkException('Argument must be an instance of string.');
86
        }
87
        $this['content_view_id'] = $contentViewId;
88
89
        return $this;
90
    }
91
92
    /**
93
     * Gets the 'content_view_id' parameter.
94
     *
95
     * @return string The Content View Mode Identifier
96
     */
97
    public function getContentViewId()
98
    {
99
        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
    public function setFraction($fraction)
112
    {
113
        if (!is_numeric($fraction)) {
114
            throw new LiftSdkException('Argument must be an instance of any numeric type (int|float).');
115
        }
116
        if ($fraction > 1 || $fraction < 0) {
117
            throw new LiftSdkException('Argument must be between 0 and 1 or those values themselves.');
118
        }
119
        $this['fraction'] = $fraction;
120
121
        return $this;
122
    }
123
124
    /**
125
     * Gets the 'fraction' parameter.
126
     *
127
     * @return int|float The fraction
128
     */
129
    public function getFraction()
130
    {
131
        return $this->getEntityValue('fraction', 0);
132
    }
133
}
134