Passed
Push — master ( ed94ae...15a67e )
by Ludwig
02:43
created

DatamolinoClient::call()   C

Complexity

Conditions 16
Paths 97

Size

Total Lines 45
Code Lines 28

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 16
eloc 28
nc 97
nop 7
dl 0
loc 45
rs 5.5666
c 0
b 0
f 0

How to fix   Complexity   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

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
    /** @var AgendaEndpoint */
28
    private $agendaEndpoint;
29
    /** @var DocumentEndpoint */
30
    private $documentEndpoint;
31
32
    public function __construct()
33
    {
34
        $this->client = new Client();
35
    }
36
37
    public function user(): UserEndpoint
38
    {
39
        if (null === $this->userEndpoint) {
40
            $this->userEndpoint = new UserEndpoint($this->getClient());
41
        }
42
43
        return $this->userEndpoint;
44
    }
45
46
    public function agenda(): AgendaEndpoint
47
    {
48
        if (null === $this->agendaEndpoint) {
49
            $this->agendaEndpoint = new AgendaEndpoint($this->getClient());
50
        }
51
52
        return $this->agendaEndpoint;
53
    }
54
55
    public function document(): DocumentEndpoint
56
    {
57
        if (null === $this->documentEndpoint) {
58
            $this->documentEndpoint = new DocumentEndpoint($this->getClient());
59
        }
60
61
        return $this->documentEndpoint;
62
    }
63
64
    /**
65
     * @return Client
66
     */
67
    public function getClient(): Client
68
    {
69
        return $this->client;
70
    }
71
}
72