Passed
Pull Request — develop (#83)
by
unknown
12:02
created

Client::getEvents()   F

Complexity

Conditions 28
Paths > 20000

Size

Total Lines 126
Code Lines 60

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 20
CRAP Score 236.3273

Importance

Changes 6
Bugs 0 Features 1
Metric Value
cc 28
eloc 60
nc 24304
nop 13
dl 0
loc 126
ccs 20
cts 56
cp 0.357
crap 236.3273
rs 0
c 6
b 0
f 1

How to fix   Long Method    Complexity    Many Parameters   

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:

Many Parameters

Methods with many parameters are not only hard to understand, but their parameters also often become inconsistent when you need more, or different data.

There are several approaches to avoid long parameter lists:

1
<?php
2
3
declare(strict_types=1);
4
5
namespace InShore\Bookwhen;
6
7
use GuzzleHttp;
8
use GuzzleHttp\Client as GuzzleClient;
9
use GuzzleHttp\Psr7\Request;
10
use InShore\Bookwhen\Exceptions\ConfigurationException;
11
use InShore\Bookwhen\Exceptions\RestException;
12
use InShore\Bookwhen\Exceptions\ValidationException;
13
use InShore\Bookwhen\Interfaces\ClientInterface;
14
use InShore\Bookwhen\Validator;
15
use Monolog\Level;
16
use Monolog\Logger;
17
use Monolog\Handler\StreamHandler;
18
use Psr\Http\Message\ResponseInterface;
19
use InShore\Bookwhen\Resources\Attachments;
20
use InShore\Bookwhen\Resources\ClassPasses;
21
use InShore\Bookwhen\Resources\Events;
22
use InShore\Bookwhen\Resources\Locations;
23
use InShore\Bookwhen\Resources\Tickets;
24
25
/**
26
 * Class Client
27
 *
28
 * The main class for API consumption
29
 *
30
 * @package inshore\bookwhen
31
 * @todo comments
32
 * @todo externalise config
33
 * @todo fix token
34
 */
35
class Client implements ClientInterface
36
{
37
    /**
38
     * {@inheritDoc}
39
     * @see \InShore\Bookwhen\Interfaces\ClientInterface::__construct()
40
     * @todo sanity check the log level passed in an exception if wrong.
41
     * @todo handle guzzle error
42
     */
43
    public function __construct(private $transporter)
44
    {
45
    }
46
47
    /**
48
     *
49
     */
50
    public function attachments(): Attachments
51
    {
52
        return new Attachments($this->transporter);
53
    }
54
55
    /**
56
57
     */
58
    public function classPasses(): ClassPasses
59
    {
60
        return new ClassPasses($this->transporter);
61
    }
62
/*
63
 *
64
 */
65 12
    public function events(): Events
66
    {
67
        return new Events($this->transporter);
68
    }
69
   /**
70
71
    */
72
    public function locations(): Locations
73
    {
74
        return new Locations($this->transporter);
75
    }
76 12
/**
77 12
78 12
 */
79
    public function tickets(): Tickets
80 12
    {
81 12
        return new Tickets($this->transporter);
82
    }
83 12
}
84
85
// EOF!
86