Passed
Push — master ( 30e7f6...e34ab3 )
by Hector Luis
12:09
created

Credentials   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
eloc 11
c 1
b 0
f 0
dl 0
loc 30
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getAll() 0 3 1
A set() 0 7 3
1
<?php
2
declare(strict_types=1);
3
4
/**
5
 * Gateway Class
6
 * @category    Ticaje
7
 * @package     Ticaje_Connector
8
 * @author      Hector Luis Barrientos <[email protected]>
9
 */
10
11
namespace Ticaje\Connector\Gateway\Provider;
12
13
use Ticaje\Base\Traits\Getter;
14
use Ticaje\Connector\Interfaces\CredentialInterface;
15
16
/**
17
 * Class Credentials
18
 * @package Ticaje\Connector\Gateway\Provider
19
 */
20
class Credentials implements CredentialInterface
21
{
22
    use Getter;
23
24
    private $username;
25
26
    private $password;
27
28
    private $host;
29
30
    private $port;
31
32
    /**
33
     * @inheritDoc
34
     */
35
    public function set(array $credentials): CredentialInterface
36
    {
37
        $attributes = array_keys(get_object_vars($this));
38
        foreach ($attributes as $attribute) {
39
            $this->$attribute = isset($credentials[$attribute]) ? $credentials[$attribute] : null;
40
        }
41
        return $this;
42
    }
43
44
    /**
45
     * @inheritDoc
46
     */
47
    public function getAll(): array
48
    {
49
        return get_object_vars($this);
50
    }
51
}
52