BasicAuthentication::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 6
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 3
1
<?php
2
3
namespace Integracao\ControlPay\Impl;
4
5
use Integracao\ControlPay\Interfaces\IAuthentication;
6
7
/**
8
 * Class BasicAuthentication
9
 * @package Integracao\ControlPay\Impl
10
 */
11
class BasicAuthentication implements IAuthentication
12
{
13
14
    /**
15
     * @var string
16
     */
17
    private $user;
18
19
    /**
20
     * @var string
21
     */
22
    private $password;
23
24
    /**
25
     * @var string
26
     */
27
    private $key;
28
29
    /**
30
     * BasicAuthentication constructor.
31
     *
32
     * @param string $user
33
     * @param string $password
34
     */
35
    public function __construct($user, $password, $key = null)
36
    {
37
        $this->user = $user;
38
        $this->password = $password;
39
        $this->key = $key;
40
    }
41
42
    /**
43
     * @return string
44
     * @throws \Exception
45
     */
46
    public function getAuthorization()
47
    {
48
        throw new \Exception("Basic authenticanão não é suportado pela api por enquanto");
49
50
        if(!empty($this->key))
0 ignored issues
show
Unused Code introduced by
if (!empty($this->key)) ...sic %s', $this->key); } does not seem to be reachable.

This check looks for unreachable code. It uses sophisticated control flow analysis techniques to find statements which will never be executed.

Unreachable code is most often the result of return, die or exit statements that have been added for debug purposes.

function fx() {
    try {
        doSomething();
        return true;
    }
    catch (\Exception $e) {
        return false;
    }

    return false;
}

In the above example, the last return false will never be executed, because a return statement has already been met in every possible execution path.

Loading history...
51
            return sprintf("Basic %s", $this->key);
52
53
        return sprintf("Basic %s", base64_encode(sprintf("%s:%s", $this->user, $this->password)));
54
    }
55
56
    /**
57
     * @return string
58
     */
59
    public function getUser()
60
    {
61
        return $this->user;
62
    }
63
64
    /**
65
     * @param string $user
66
     * @return BasicAuthentication
67
     */
68
    public function setUser($user)
69
    {
70
        $this->user = $user;
71
        return $this;
72
    }
73
74
    /**
75
     * @return string
76
     */
77
    public function getPassword()
78
    {
79
        return $this->password;
80
    }
81
82
    /**
83
     * @param string $password
84
     * @return BasicAuthentication
85
     */
86
    public function setPassword($password)
87
    {
88
        $this->password = $password;
89
        return $this;
90
    }
91
92
}