Completed
Push — master ( 5ba59a...5157fd )
by Denis
02:04
created

ArticleCollection::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 6
Ratio 100 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 6
loc 6
ccs 0
cts 4
cp 0
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 5
crap 2
1
<?php
2
3
namespace Lan\Ebs\Sdk\Collection;
4
5
use Exception;
6
use Lan\Ebs\Sdk\Classes\Collection;
7
use Lan\Ebs\Sdk\Client;
8
use Lan\Ebs\Sdk\Model\Article;
9
10 View Code Duplication
class ArticleCollection extends Collection
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
11
{
12
    private $issueId = null;
13
14
    /**
15
     * BookCollection constructor.
16
     * @param Client $client
17
     * @param array $fields
18
     * @param int $limit
19
     * @param int $offset
20
     * @throws Exception
21
     */
22
    public function __construct($issueId, Client $client, array $fields = [], $limit = 10, $offset = 0)
23
    {
24
        parent::__construct($client, $fields, Article::class, $limit, $offset);
25
26
        $this->issueId = $issueId;
27
    }
28
29
    /**
30
     * @param $method
31
     * @param array $params
32
     * @return array
33
     * @throws Exception
34
     */
35
    public function getUrl($method, array $params = [])
36
    {
37
        switch ($method) {
38
            case 'load':
39
                return [
40
                    'url' => '/1.0/resource/journal/issue/' . ((int)$this->issueId),
41
                    'method' => 'GET',
42
                    'code' => '200'
43
                ];
44
            default:
45
                throw new Exception('Route for ' . $method . ' not found');
46
        }
47
    }
48
}