DatamolinoClient::document()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 3
nc 2
nop 0
dl 0
loc 7
rs 10
c 0
b 0
f 0
1
<?php
2
3
/*
4
 * This file is part of datamolino client.
5
 *
6
 * (c) 2018 cwd.at GmbH <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
declare(strict_types=1);
13
14
namespace Cwd\Datamolino;
15
16
use Cwd\Datamolino\Endpoints\AgendaEndpoint;
17
use Cwd\Datamolino\Endpoints\DocumentEndpoint;
18
use Cwd\Datamolino\Endpoints\UserEndpoint;
19
20
class DatamolinoClient
21
{
22
    /** @var Client */
23
    private $client;
24
25
    /** @var UserEndpoint */
26
    private $userEndpoint;
27
28
    /** @var AgendaEndpoint */
29
    private $agendaEndpoint;
30
31
    /** @var DocumentEndpoint */
32
    private $documentEndpoint;
33
34
    public function __construct(?Client $client = null)
35
    {
36
        if (null === $client) {
37
            $this->client = new Client();
38
        } else {
39
            $this->client = $client;
40
        }
41
    }
42
43
    public function user(): UserEndpoint
44
    {
45
        if (null === $this->userEndpoint) {
46
            $this->userEndpoint = new UserEndpoint($this->getClient());
47
        }
48
49
        return $this->userEndpoint;
50
    }
51
52
    public function agenda(): AgendaEndpoint
53
    {
54
        if (null === $this->agendaEndpoint) {
55
            $this->agendaEndpoint = new AgendaEndpoint($this->getClient());
56
        }
57
58
        return $this->agendaEndpoint;
59
    }
60
61
    public function document(): DocumentEndpoint
62
    {
63
        if (null === $this->documentEndpoint) {
64
            $this->documentEndpoint = new DocumentEndpoint($this->getClient());
65
        }
66
67
        return $this->documentEndpoint;
68
    }
69
70
    /**
71
     * @return Client
72
     */
73
    public function getClient(): Client
74
    {
75
        return $this->client;
76
    }
77
}
78