TestsAuthentication   A
last analyzed

Complexity

Total Complexity 8

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 0
Metric Value
wmc 8
lcom 1
cbo 0
dl 0
loc 37
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 16 4
A isAuthenticationSetup() 0 4 2
A getUsername() 0 4 1
A getPassword() 0 4 1
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