Test Failed
Pull Request — master (#46)
by Yuji
04:29
created

AbstractRequest   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 42
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 1
dl 0
loc 42
rs 10
c 0
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
api() 0 1 ?
response() 0 1 ?
validateParams() 0 1 ?
A getParams() 0 6 1
A requires() 0 5 2
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