Completed
Push — master ( 73b08b...9131b2 )
by Laurens
02:28
created

ApiScope::setProductScope()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 3
cts 3
cp 1
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 1
crap 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace LauLamanApps\IzettleApi\Client;
6
7
use LauLamanApps\IzettleApi\Client\ApiScope\Rights;
8
9
final class ApiScope
10
{
11
    private const FINANCE = 'FINANCE';
12
    private const PURCHASE = 'PURCHASE';
13
    private const PRODUCT = 'PRODUCT';
14
    private const INVENTORY = 'INVENTORY';
15
    private const IMAGE = 'IMAGE';
16
17
    /**
18
     * @var Rights
19
     */
20
    private $finance;
21
22
    /**
23
     * @var Rights
24
     */
25
    private $purchase;
26
27
    /**
28
     * @var Rights
29
     */
30
    private $product;
31
32
    /**
33
     * @var Rights
34
     */
35
    private $inventory;
36
37
    /**
38
     * @var Rights
39
     */
40
    private $image;
41
42 2
    public function setFinancesScope(Rights $rights): void
43
    {
44 2
        $this->finance = $rights;
45 2
    }
46
47 2
    public function setPurchaseScope(Rights $rights): void
48
    {
49 2
        $this->purchase = $rights;
50 2
    }
51
52 2
    public function setProductScope(Rights $rights): void
53
    {
54 2
        $this->product = $rights;
55 2
    }
56
57 2
    public function setInventoryScope(Rights $rights): void
58
    {
59 2
        $this->inventory = $rights;
60 2
    }
61
62 2
    public function setImageScope(Rights $rights): void
63
    {
64 2
        $this->image = $rights;
65 2
    }
66
67 11
    public function getUrlParameters(): string
68
    {
69 11
        $scope = [];
70 11
        if (!is_null($this->finance)) {
71 2
            $scope[] = self::FINANCE . ':' . $this->finance->getValue();
72
        }
73 11
        if (!is_null($this->purchase)) {
74 2
            $scope[] = self::PURCHASE . ':' . $this->purchase->getValue();
75
        }
76 11
        if (!is_null($this->product)) {
77 2
            $scope[] = self::PRODUCT . ':' . $this->product->getValue();
78
        }
79 11
        if (!is_null($this->inventory)) {
80 2
            $scope[] = self::INVENTORY . ':' . $this->inventory->getValue();
81
        }
82 11
        if (!is_null($this->image)) {
83 2
            $scope[] = self::IMAGE . ':' . $this->image->getValue();
84
        }
85
86 11
        return implode(' ', $scope);
87
    }
88
}
89