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

Credentials::set()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 4
c 1
b 0
f 0
dl 0
loc 7
rs 10
cc 3
nc 3
nop 1
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