Completed
Pull Request — master (#2)
by Michał
01:49
created

BarenoteClient::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 7
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 4
nc 1
nop 0
1
<?php
2
namespace Barenote;
3
4
5
use Barenote\Domain\Credentials;
6
use Barenote\Endpoint\Authentication;
7
use Barenote\Transport\HttpfulTransport;
8
use Barenote\Transport\Transport;
9
10
class BarenoteClient
11
{
12
    /**
13
     * @var Transport
14
     */
15
    private $transport;
16
    private $endpoints = [];
17
18
    /**
19
     * BarenoteClient constructor.
20
     */
21
    public function __construct()
22
    {
23
        $this->transport = new HttpfulTransport();
24
        $this->transport->setHost("http://localhost:8080");
25
26
        $this->endpoints['authentication'] = new Authentication($this->transport);
27
    }
28
29
    public function authenticate(string $username, string $password)
30
    {
31
        $credentials = new Credentials($username, $password);
32
        $this->getAuthenticationEndpoint()->authenticate($credentials);
33
    }
34
35
    /**
36
     * @return Authentication
37
     */
38
    public function getAuthenticationEndpoint()
39
    {
40
        return $this->endpoints['authentication'];
41
    }
42
}