Completed
Push — master ( 5f50d9...cf27fb )
by Vladimir
02:07
created

AuthenticatedClient   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 0
Metric Value
wmc 5
lcom 1
cbo 0
dl 0
loc 28
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 13 3
A isAuthenticationSetup() 0 4 1
A getApiToken() 0 4 1
1
<?php
2
3
namespace allejo\DaPulse\Tests\Utilities;
4
5
class AuthenticatedClient
6
{
7
    private $apiToken;
8
9
    public function __construct ($filePath)
10
    {
11
        if (file_exists($filePath))
12
        {
13
            $file = file_get_contents($filePath, true);
14
            $json = json_decode($file, true);
15
            $this->apiToken = $json['apiToken'];
16
        }
17
        else if (getenv('apiToken') !== false)
18
        {
19
            $this->apiToken = getenv('apiToken');
20
        }
21
    }
22
23
    public function isAuthenticationSetup ()
24
    {
25
        return (isset($this->apiToken));
26
    }
27
28
    public function getApiToken()
29
    {
30
        return $this->apiToken;
31
    }
32
}
33