Threatmetrix::getSession()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
crap 1
1
<?php
2
3
namespace Omnipay\Emp;
4
5
/**
6
 * @author    Ivan Kerin <[email protected]>
7
 * @copyright 2014, Clippings Ltd.
8
 * @license   http://spdx.org/licenses/BSD-3-Clause
9
 */
10
class Threatmetrix
11
{
12
    /**
13
     * @var string
14
     */
15
    private $organizationId;
16
17
    /**
18
     * @var string
19
     */
20
    private $sessionId;
21
22
    /**
23
     * @var string
24
     */
25
    private $session;
26
27
    /**
28
     * @param string $organizationId
29
     * @param string $clientId
30
     */
31 1
    public function __construct($organizationId, $clientId)
32
    {
33 1
        $this->organizationId = $organizationId;
34 1
        $this->sessionId = $clientId.date('Ymdhis').rand(100000,999999);;
0 ignored issues
show
Coding Style introduced by
It is generally recommended to place each PHP statement on a line by itself.

Let’s take a look at an example:

// Bad
$a = 5; $b = 6; $c = 7;

// Good
$a = 5;
$b = 6;
$c = 7;
Loading history...
35 1
        $this->session = md5(rand());
36 1
    }
37
38
    /**
39
     * @return string
40
     */
41 1
    public function getOrganizationId()
42
    {
43 1
        return $this->organizationId;
44
    }
45
46
    /**
47
     * @return string
48
     */
49 1
    public function getSessionId()
50
    {
51 1
        return $this->sessionId;
52
    }
53
54
    /**
55
     * @return string
56
     */
57 1
    public function getSession()
58
    {
59 1
        return $this->session;
60
    }
61
62
    /**
63
     * @return string
64
     */
65 1
    public function getUrlQuery()
66
    {
67 1
        return http_build_query(array(
68 1
            'org_id' => $this->organizationId,
69 1
            'session_id' => $this->sessionId,
70 1
        ));
71
    }
72
73
    /**
74
     * Return the tracking code, that has to be placed to the page where the payment form is
75
     *
76
     * @return string
77
     */
78 1
    public function getTrackingCode()
79
    {
80 1
        $urlQuery = $this->getUrlQuery();
81
82
        return <<<TRACKING
83
<div style="position:absolute;left:0;bottom:0">
84 1
<p style="margin:0;background:url(https://h.online-metrix.net/fp/clear.png?{$urlQuery}&session2={$this->session}&m=1)"></p>
85 1
<img src="https://h.online-metrix.net/fp/clear.png?{$urlQuery}&m=2"/>
86 1
<script src="https://h.online-metrix.net/fp/check.js?{$urlQuery}"></script>
87 1
<object type="application/x-shockwave-flash" data="https://h.online-metrix.net/fp/fp.swf?{$urlQuery}" width="1" height="1" id="thm_fp">
88 1
<param name="movie" value="https://h.online-metrix.net/fp/fp.swf?{$urlQuery}" />
89
</object>
90 1
</div>
91 1
TRACKING;
92
    }
93
94
    /**
95
     * @return string
96
     */
97 1
    public function getTrackingUrl()
98
    {
99 1
        $urlQuery = $this->getUrlQuery();
100
101 1
        return "https://h.online-metrix.net/fp/clear.png?{$urlQuery}&m=2";
102
    }
103
}
104