Completed
Push — master ( 1392b0...257c81 )
by Denis
01:57
created

User::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 3
cts 3
cp 1
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 2
crap 1
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 7
    public function __construct(Client $client, array $fields = [])
36
    {
37 7
        parent::__construct($client, $fields);
38 7
    }
39
40 3
    public function getUrl($method, array $params = [])
41
    {
42
        switch ($method) {
43 3
            case 'get':
44
                return [
45 1
                    'url' => vsprintf('/1.0/security/user/get/%d', $params),
46 1
                    'method' => 'GET',
47 1
                    'code' => 200
48
                ];
49 3
            case 'post':
50
                return [
51 1
                    'url' => '/1.0/security/user/post',
52
                    'params' => [],
53
                    'method' => 'POST',
54
                    'code' => 201
55
                ];
56 2
            case 'put':
57
                return [
58 1
                    'url' => vsprintf('/1.0/security/user/put/%d', $params),
59 1
                    'method' => 'PUT',
60 1
                    'code' => 200
61
                ];
62 1
            case 'delete':
63
                return [
64 1
                    'url' => vsprintf('/1.0/security/user/delete/%d', $params),
65 1
                    'method' => 'DELETE',
66 1
                    'code' => 200
67
                ];
68
            default:
69
                throw new Exception('Route for ' . $method . ' not found');
70
        }
71
    }
72
}