Completed
Pull Request — master (#1)
by Paulius
02:07
created

Authentication   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 57
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 21
c 1
b 0
f 0
dl 0
loc 57
rs 10
wmc 6

3 Methods

Rating   Name   Duplication   Size   Complexity  
A toArray() 0 5 1
A __construct() 0 5 1
A getEndpointUrl() 0 10 4
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
    public function __construct(string $username, string $password, string $country = 'EE')
38
    {
39
        $this->username = $username;
0 ignored issues
show
Bug Best Practice introduced by
The property username does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
40
        $this->password = $password;
0 ignored issues
show
Bug Best Practice introduced by
The property password does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
41
        $this->country = $country;
0 ignored issues
show
Bug Best Practice introduced by
The property country does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
42
    }
43
44
    public function toArray(): array
45
    {
46
        return [
47
            'username' => $this->username,
48
            'password' => $this->password
49
        ];
50
    }
51
52
    public function getEndpointUrl(): string
53
    {
54
        switch ($this->country) {
55
            case 'LT':
56
                return self::LT_PRODUCTION_ENDPOINT_URL;
57
            case 'LV':
58
                return self::LV_PRODUCTION_ENDPOINT_URL;
59
            case 'EE':
60
            default:
61
                return self::EE_PRODUCTION_ENDPOINT_URL;
62
        }
63
    }
64
}