Authentication::toArray()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 3
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 5
rs 10
1
<?php
2
3
namespace DPD\Interconnector;
4
5
class Authentication
6
{
7
    /**
8
     * test endpoint for Estonia
9
     */
10
    const EE_TEST_ENDPOINT_URL = 'https://ee.integration.dpd.eo.pl/ws-mapper-rest/';
11
12
    /**
13
     * production endpoint for Estonia
14
     */
15
    const EE_PRODUCTION_ENDPOINT_URL = 'https://integration.dpd.ee:8443/ws-mapper-rest/';
16
17
    /**
18
     * test endpoint for Latvia
19
     */
20
    const LV_TEST_ENDPOINT_URL = 'https://lv.integration.dpd.eo.pl/ws-mapper-rest/';
21
22
    /**
23
     * production endpoint for Latvia
24
     */
25
    const LV_PRODUCTION_ENDPOINT_URL = 'https://integration.dpd.lv:8443/ws-mapper-rest/';
26
27
    /**
28
     * test endpoint for Lithuania
29
     */
30
    const LT_TEST_ENDPOINT_URL = 'https://lt.integration.dpd.eo.pl/ws-mapper-rest/';
31
32
    /**
33
     * production endpoint for Lithuania
34
     */
35
    const LT_PRODUCTION_ENDPOINT_URL = 'https://integracijos.dpd.lt/ws-mapper-rest/';
36
37
    private $username;
38
    private $password;
39
    private $country;
40
41
    public function __construct(string $username, string $password, string $country = 'EE')
42
    {
43
        $this->username = $username;
44
        $this->password = $password;
45
        $this->country = $country;
46
    }
47
48
    public function toArray(): array
49
    {
50
        return [
51
            'username' => $this->username,
52
            'password' => $this->password
53
        ];
54
    }
55
56
    public function getEndpointUrl(): string
57
    {
58
        $const = $this->country . '_PRODUCTION_ENDPOINT_URL';
59
60
        return constant('self::' . $const);
61
    }
62
}