Completed
Push — master ( db0246...91f80b )
by Denis
02:07
created

User   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 52
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 6
lcom 0
cbo 1
dl 0
loc 52
ccs 7
cts 7
cp 1
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
B getUrl() 0 32 5
1
<?php
2
/**
3
 * Created by PhpStorm.
4
 * User: dp
5
 * Date: 26.07.17
6
 * Time: 11:57
7
 */
8
9
namespace Lan\Ebs\Sdk\Model;
10
11
use Exception;
12
use Lan\Ebs\Sdk\Classes\Model;
13
use Lan\Ebs\Sdk\Client;
14
15
/**
16
 * @property mixed login
17
 * @property mixed email
18
 * @property mixed fio
19
 * @property mixed registered_at
20
 */
21
class User extends Model
22
{
23
    const FIELD_LOGIN = 'login';
24
    const FIELD_EMAIL = 'email';
25
    const FIELD_FIO = 'fio';
26
    const FIELD_REGISTERED = 'registered_at';
27
28
    public static $defaultFields = [
29
        User::FIELD_LOGIN,
30
        User::FIELD_EMAIL,
31
        User::FIELD_FIO,
32
        User::FIELD_REGISTERED
33
    ];
34
35 4
    public function __construct(Client $client, array $fields = [])
36
    {
37 4
        parent::__construct($client, $fields);
38 4
    }
39
40 1
    public function getUrl($method, array $params = [])
41
    {
42
        switch ($method) {
43 1
            case 'get':
44
                return [
45
                    'url' => vsprintf('/1.0/security/user/get/%d', $params),
46
                    'method' => 'GET',
47
                    'code' => 200
48
                ];
49 1
            case 'post':
50
                return [
51 1
                    'url' => '/1.0/security/user/post',
52
                    'params' => [],
53
                    'method' => 'POST',
54
                    'code' => 201
55
                ];
56
            case 'put':
57
                return [
58
                    'url' => vsprintf('/1.0/security/user/put/%d', $params),
59
                    'method' => 'PUT',
60
                    'code' => 200
61
                ];
62
            case 'delete':
63
                return [
64
                    'url' => vsprintf('/1.0/security/user/delete/%d', $params),
65
                    'method' => 'DELETE',
66
                    'code' => 200
67
                ];
68
            default:
69
                throw new Exception('Route for ' . $method . ' not found');
70
        }
71
    }
72
}