Code Duplication    Length = 21-27 lines in 3 locations

src/collection/BookCollection.php 1 location

@@ 16-36 (lines=21) @@
13
use Lan\Ebs\Sdk\Client;
14
use Lan\Ebs\Sdk\Model\Book;
15
16
class BookCollection extends Collection
17
{
18
    public function __construct(Client $client, array $fields = [], $limit = 10, $offset = 0)
19
    {
20
        parent::__construct($client, $fields, Book::class, $limit, $offset);
21
    }
22
23
    public function getUrl($method, array $params = [])
24
    {
25
        switch ($method) {
26
            case 'load':
27
                return [
28
                    'url' => '/1.0/resource/book',
29
                    'method' => 'GET',
30
                    'code' => '200'
31
                ];
32
            default:
33
                throw new Exception('Route for ' . $method . ' not found');
34
        }
35
    }
36
}

src/collection/UserCollection.php 1 location

@@ 16-36 (lines=21) @@
13
use Lan\Ebs\Sdk\Client;
14
use Lan\Ebs\Sdk\Model\User;
15
16
class UserCollection extends Collection
17
{
18
    public function __construct(Client $client, array $fields = [], $limit = 10, $offset = 0)
19
    {
20
        parent::__construct($client, $fields, User::class, $limit, $offset);
21
    }
22
23
    public function getUrl($method, array $params = [])
24
    {
25
        switch ($method) {
26
            case 'load':
27
                return [
28
                    'url' => '/1.0/security/user',
29
                    'method' => 'GET',
30
                    'code' => '200'
31
                ];
32
            default:
33
                throw new Exception('Route for ' . $method . ' not found');
34
        }
35
    }
36
}

src/model/Book.php 1 location

@@ 21-47 (lines=27) @@
18
 * @property mixed fio
19
 * @property mixed registered_at
20
 */
21
class Book extends Model
22
{
23
    const FIELD_NAME = 'name';
24
25
    public static $defaultFields = [
26
        Book::FIELD_NAME,
27
    ];
28
29
    public function __construct(Client $client, array $fields = [])
30
    {
31
        parent::__construct($client, $fields);
32
    }
33
34
    public function getUrl($method, array $params = [])
35
    {
36
        switch ($method) {
37
            case 'get':
38
                return [
39
                    'url' => vsprintf('/1.0/resource/book/get/%d', $params),
40
                    'method' => 'GET',
41
                    'code' => 200
42
                ];
43
            default:
44
                throw new Exception('Route for ' . $method . ' not found');
45
        }
46
    }
47
}