Completed
Push — master ( 85a630...b97b88 )
by Dmitry
02:41
created

TransportRequest   A

Complexity

Total Complexity 11

Size/Duplication

Total Lines 97
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 61.9%

Importance

Changes 0
Metric Value
wmc 11
lcom 1
cbo 2
dl 0
loc 97
ccs 13
cts 21
cp 0.619
rs 10
c 0
b 0
f 0

7 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A getService() 0 4 1
A getMethod() 0 4 1
A getParams() 0 4 1
A getUseOperatorUnits() 0 4 1
B setUseOperatorUnits() 0 11 5
A getCredentials() 0 4 1
1
<?php
2
/**
3
 * @author Dmitry Gladyshev <[email protected]>
4
 * @date 17/08/2016 13:52
5
 */
6
7
namespace Yandex\Direct\Transport;
8
9
use Yandex\Direct\ConfigurableTrait;
10
use Yandex\Direct\CredentialsInterface;
11
use Yandex\Direct\Exception\InvalidArgumentException;
12
13
/**
14
 * Class TransportRequest
15
 * @package Yandex\Direct
16
 */
17
class TransportRequest
18
{
19
    use ConfigurableTrait;
20
21
    /**
22
     * @var string
23
     */
24
    protected $useOperatorUnits = 'true';
25
26
    /**
27
     * @var string
28
     */
29
    protected $method;
30
31
    /**
32
     * @var string
33
     */
34
    protected $service;
35
36
    /**
37
     * @var array
38
     */
39
    protected $params = [];
40
41
    /**
42
     * Custom headers
43
     * @var array
44
     */
45
    protected $headers = [];
46
47
    /**
48
     * @var CredentialsInterface
49
     */
50
    protected $credentials;
51
52
53 1
    public function __construct(array $options = [])
54
    {
55 1
        $this->setOptions($options);
56 1
    }
57
58
    /**
59
     * @return string
60
     */
61 1
    public function getService()
62
    {
63 1
        return $this->service;
64
    }
65
66
    /**
67
     * @return string
68
     */
69 1
    public function getMethod()
70
    {
71 1
        return $this->method;
72
    }
73
74
    /**
75
     * @return array
76
     */
77 1
    public function getParams()
78
    {
79 1
        return $this->params;
80
    }
81
82
    /**
83
     * @return string
84
     */
85 1
    public function getUseOperatorUnits()
86
    {
87 1
        return $this->useOperatorUnits;
88
    }
89
90
    /**
91
     * @param bool $useOperatorUnits
92
     * @throws InvalidArgumentException
93
     */
94
    public function setUseOperatorUnits($useOperatorUnits)
95
    {
96
        if (is_numeric($useOperatorUnits) || is_bool($useOperatorUnits)) {
97
            $this->useOperatorUnits = $useOperatorUnits ? 'true' : 'false';
98
        } else {
99
            if (!in_array($useOperatorUnits, ['true', 'false'])) {
100
                throw new InvalidArgumentException("Invalid value `\$seOperatorUnits`, valid is boolean and `true` or `false`.");
101
            }
102
            $this->useOperatorUnits = $useOperatorUnits;
103
        }
104
    }
105
106
    /**
107
     * @return CredentialsInterface
108
     */
109 1
    public function getCredentials()
110
    {
111 1
        return $this->credentials;
112
    }
113
}
114