Completed
Push — master ( 37427d...780143 )
by Dmitry
02:21
created

Request::getMethod()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
crap 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 Request implements RequestInterface
18
{
19
    use ConfigurableTrait;
20
21
    /**
22
     * @var bool
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 string
38
     */
39
    protected $language = self::LANGUAGE_RU;
40
41
    /**
42
     * @var array
43
     */
44
    protected $params = [];
45
46
    /**
47
     * Custom headers
48
     * @var array
49
     */
50
    protected $headers = [];
51
52
    /**
53
     * @var CredentialsInterface
54
     */
55
    protected $credentials;
56
57
    /**
58
     * @inheritdoc
59
     */
60
    public static function fromArray(array $requestAttributes)
61
    {
62
        $instance = new static;
63
        $instance->setOptions($requestAttributes);
64
        return $instance;
65
    }
66
67
    /**
68
     * Request constructor.
69
     * @param array $requestAttributes
70
     */
71 2
    public function __construct(array $requestAttributes = [])
72
    {
73 2
        $this->setOptions($requestAttributes);
74 2
    }
75
76
    /**
77
     * @return string
78
     */
79 1
    public function getService()
80
    {
81 1
        return $this->service;
82
    }
83
84
    /**
85
     * @return string
86
     */
87 1
    public function getMethod()
88
    {
89 1
        return $this->method;
90
    }
91
92
    /**
93
     * @return array
94
     */
95 1
    public function getParams()
96
    {
97 1
        return $this->params;
98
    }
99
100
    /**
101
     * @return string
102
     */
103 1
    public function getUseOperatorUnits()
104
    {
105 1
        return $this->useOperatorUnits;
106
    }
107
108
    /**
109
     * @param bool $useOperatorUnits
110
     * @throws InvalidArgumentException
111
     */
112 1
    public function setUseOperatorUnits($useOperatorUnits)
113
    {
114 1
        $this->useOperatorUnits = $useOperatorUnits;
115 1
    }
116
117
    /**
118
     * @inheritdoc
119
     */
120 1
    public function getCredentials()
121
    {
122 1
        return $this->credentials;
123
    }
124
125
    /**
126
     * @inheritdoc
127
     */
128 1
    public function getLanguage()
129
    {
130 1
        return $this->language;
131
    }
132
}
133