Test Failed
Pull Request — master (#19)
by Aya
04:08
created

AbstractRequest::getParams()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 6
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 0
1
<?php
2
3
namespace Shippinno\YahooShoppingJp\Request;
4
5
use Shippinno\YahooShoppingJp\Api\AbstractApi;
6
use Shippinno\YahooShoppingJp\Exception\InvalidRequestException;
7
use Shippinno\YahooShoppingJp\Response\AbstractResponse;
8
9
abstract class AbstractRequest
10
{
11
    /**
12
     * @var array
13
     */
14
    protected $params;
15
16
    /**
17
     * @return AbstractApi
18
     */
19
    abstract public function api();
20
21
    /**
22
     * @return AbstractResponse
23
     */
24
    abstract public function response();
25
26
    /**
27
     * @return void
28
     */
29
    abstract protected function validateParams();
30
31
    /**
32
     * @return string|array
33
     */
34
    public function getParams()
35
    {
36
        $this->validateParams();
37
38
        return $this->params;
39
    }
40
41
    /**
42
     * @param string $paramKey
43
     * @throws InvalidRequestException
44
     */
45
    public function requires($paramKey) {
46
        if (! isset($this->params[$paramKey])) {
47
            throw new InvalidRequestException($paramKey.' is required');
48
        }
49
    }
50
}
51