TestsAuthentication::isAuthenticationSetup()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 2
nc 2
nop 0
1
<?php
2
3
class TestsAuthentication
4
{
5
    private $username;
6
    private $password;
7
8
    public function __construct ($filePath)
9
    {
10
        if (file_exists($filePath))
11
        {
12
            $file = file_get_contents($filePath, true);
13
            $json = json_decode($file, true);
14
15
            $this->username = $json['username'];
16
            $this->password = $json['password'];
17
        }
18
        else if (getenv('username') !== false && getenv('password') !== false)
19
        {
20
            $this->username = getenv('username');
21
            $this->password = getenv('password');
22
        }
23
    }
24
25
    public function isAuthenticationSetup ()
26
    {
27
        return (isset($this->username) && isset($this->password));
28
    }
29
30
    public function getUsername ()
31
    {
32
        return $this->username;
33
    }
34
35
    public function getPassword ()
36
    {
37
        return $this->password;
38
    }
39
}
40