Completed
Pull Request — master (#15)
by Nick
03:56
created

DecideResponse::getTouchIdentifier()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 6
rs 9.4285
cc 1
eloc 3
nc 1
nop 0
1
<?php
2
3
namespace Acquia\LiftClient\Entity;
4
5
class DecideResponse extends Entity
6
{
7
    /**
8
     * Gets the 'touch_identifier' parameter.
9
     *
10
     * @throws \Acquia\LiftClient\Exception\LiftSdkException
11
     *
12
     * @return string
13
     */
14
    public function getTouchIdentifier()
15
    {
16
        $lwr = $this->getLiftWebResponse();
17
18
        return $lwr->getEntityValue('touch_identifier', '');
19
    }
20
21
    private function getLiftWebResponse()
22
    {
23
        $lwr = $this->getEntityValue('lift_web_response', []);
24
25
        return new Entity($lwr);
26
    }
27
28
    /**
29
     * Gets the 'identity' parameter.
30
     *
31
     * @throws \Acquia\LiftClient\Exception\LiftSdkException
32
     *
33
     * @return string
34
     */
35
    public function getIdentity()
36
    {
37
        $lwr = $this->getLiftWebResponse();
38
39
        return $lwr->getEntityValue('identity', '');
40
    }
41
42
    /**
43
     * Gets the 'identity_source' parameter.
44
     *
45
     * Type of visitor's primary identity information. Specific string (account, email,
46
     * facebook, twitter, tracking, name) or custom identifier type
47
     *
48
     * @throws \Acquia\LiftClient\Exception\LiftSdkException
49
     *
50
     * @return int
51
     */
52
    public function getIdentityExpiry()
53
    {
54
        $lwr = $this->getLiftWebResponse();
55
56
        return $lwr->getEntityValue('identity_expiry', 0);
57
    }
58
59
    /**
60
     * Gets the 'segments' parameter.
61
     *
62
     * @return Segment[]
63
     */
64 View Code Duplication
    public function getMatchedSegments()
65
    {
66
        $lwr = $this->getLiftWebResponse();
67
        $ret = [];
68
        $segments = $lwr->getEntityValue('segments', []);
69
        foreach ($segments as $segment) {
70
            $ret[] = new Segment($segment);
71
        }
72
73
        return $ret;
74
    }
75
76
    /**
77
     * gets the 'set_do_not_track' parameter.
78
     *
79
     * Flag to indicate whether the person should not be tracked
80
     *
81
     * @throws \Acquia\LiftClient\Exception\LiftSdkException
82
     *
83
     * @return bool
84
     */
85
    public function getSetDoNotTrack()
86
    {
87
        return $this->getEntityValue('set_do_not_track', false);
88
    }
89
90
    /**
91
     * Gets the 'matched_segments' parameter.
92
     *
93
     * @return Segment[]
94
     */
95
    public function getDecisions()
96
    {
97
        $ret = [];
98
        $decisions = $this->getEntityValue('decisions', []);
99
        foreach ($decisions as $decision) {
100
            $ret[] = new Decision($decision);
101
        }
102
103
        return $ret;
104
    }
105
}
106