Passed
Push — master ( 425228...dd83ab )
by Laurent
54s queued 11s
created

Client   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 61
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 6
eloc 10
dl 0
loc 61
rs 10
c 0
b 0
f 0

6 Methods

Rating   Name   Duplication   Size   Complexity  
A thirdparties() 0 3 1
A stockMovements() 0 3 1
A proposals() 0 3 1
A __construct() 0 4 1
A products() 0 3 1
A warehouse() 0 3 1
1
<?php
2
3
namespace Dolibarr\Client;
4
5
use Dolibarr\Client\HttpClient\HttpClient;
6
use Dolibarr\Client\HttpClient\HttpClientInterface;
7
use Dolibarr\Client\Service\ProductsService;
8
use Dolibarr\Client\Service\ProposalService;
9
use Dolibarr\Client\Service\StockMovementsService;
10
use Dolibarr\Client\Service\ThirdPartiesService;
11
use Dolibarr\Client\Service\WarehousesService;
12
use JMS\Serializer\SerializerInterface;
13
14
/**
15
 * @author Laurent De Coninck <[email protected]>
16
 */
17
final class Client
18
{
19
20
    /**
21
     * @var HttpClient
22
     */
23
    private $httpClient;
24
25
    /**
26
     * @var SerializerInterface
27
     */
28
    private $serializer;
29
30
    /**
31
     * @param HttpClientInterface $httpClient
32
     * @param SerializerInterface $serializer
33
     */
34
    public function __construct(HttpClientInterface $httpClient, SerializerInterface $serializer)
35
    {
36
        $this->httpClient = $httpClient;
0 ignored issues
show
Documentation Bug introduced by
$httpClient is of type Dolibarr\Client\HttpClient\HttpClientInterface, but the property $httpClient was declared to be of type Dolibarr\Client\HttpClient\HttpClient. Are you sure that you always receive this specific sub-class here, or does it make sense to add an instanceof check?

Our type inference engine has found a suspicous assignment of a value to a property. This check raises an issue when a value that can be of a given class or a super-class is assigned to a property that is type hinted more strictly.

Either this assignment is in error or an instanceof check should be added for that assignment.

class Alien {}

class Dalek extends Alien {}

class Plot
{
    /** @var  Dalek */
    public $villain;
}

$alien = new Alien();
$plot = new Plot();
if ($alien instanceof Dalek) {
    $plot->villain = $alien;
}
Loading history...
37
        $this->serializer = $serializer;
38
    }
39
40
    /**
41
     * @return ThirdPartiesService
42
     */
43
    public function thirdparties()
44
    {
45
        return new ThirdPartiesService($this->httpClient, $this->serializer);
46
    }
47
48
    /**
49
     * @return ProposalService
50
     */
51
    public function proposals()
52
    {
53
        return new ProposalService($this->httpClient, $this->serializer);
54
    }
55
56
    /**
57
     * @return StockMovementsService
58
     */
59
    public function stockMovements()
60
    {
61
        return new StockMovementsService($this->httpClient, $this->serializer);
62
    }
63
64
    /**
65
     * @return WarehousesService
66
     */
67
    public function warehouse()
68
    {
69
        return new WarehousesService($this->httpClient, $this->serializer);
70
    }
71
72
    /**
73
     * @return ProductsService
74
     */
75
    public function products()
76
    {
77
        return new ProductsService($this->httpClient, $this->serializer);
78
    }
79
}
80