Passed
Pull Request — master (#77)
by Yuichi
04:41 queued 02:24
created

UserApi::generateUrl()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 3
ccs 0
cts 2
cp 0
crap 2
rs 10
1
<?php
2
3
namespace CybozuHttp\Api;
4
5
use CybozuHttp\Api\User\Csv;
6
use CybozuHttp\Api\User\Groups;
7
use CybozuHttp\Api\User\Organizations;
8
use CybozuHttp\Api\User\OrganizationUsers;
9
use CybozuHttp\Api\User\Titles;
10
use CybozuHttp\Api\User\UserGroups;
11
use CybozuHttp\Api\User\UserOrganizations;
12
use CybozuHttp\Api\User\Users;
13
use CybozuHttp\Api\User\UserServices;
14
use CybozuHttp\Client;
15
16
/**
17
 * @author ochi51 <[email protected]>
18
 */
19
class UserApi
20
{
21
    public const API_PREFIX = '/v1/';
22
23
    /**
24
     * @var Client
25
     */
26
    private $client;
27
28
    /**
29
     * @var Csv
30
     */
31
    private $csv;
32
33
    /**
34
     * @var Users
35
     */
36
    private $users;
37
38
    /**
39
     * @var Organizations
40
     */
41
    private $organizations;
42
43
    /**
44
     * @var Titles
45
     */
46
    private $titles;
47
48
    /**
49
     * @var Groups
50
     */
51
    private $groups;
52
53
    /**
54
     * @var UserOrganizations
55
     */
56
    private $userOrganizations;
57
58
    /**
59
     * @var UserGroups
60
     */
61
    private $userGroups;
62
63
    /**
64
     * @var UserServices
65
     */
66
    private $userServices;
67
68
    /**
69
     * @var OrganizationUsers
70
     */
71
    private $organizationUsers;
72
73
    public function __construct(Client $client)
74
    {
75
        $this->client = $client;
76
        $this->csv = new Csv($client);
77
        $this->users = new Users($client, $this->csv);
78
        $this->organizations = new Organizations($this->csv);
79
        $this->titles = new Titles($this->csv);
80
        $this->groups = new Groups($this->csv);
81
        $this->userOrganizations = new UserOrganizations($client, $this->csv);
82
        $this->userGroups = new UserGroups($this->csv);
83
        $this->userServices = new UserServices($this->csv);
84
        $this->organizationUsers = new OrganizationUsers($client);
85
    }
86
87
    /**
88
     * @param string $api
89
     * @return string
90
     */
91
    public static function generateUrl($api): string
92
    {
93
        return self::API_PREFIX . $api;
94
    }
95
96
    /**
97
     * @return Client
98
     */
99
    public function getClient(): Client
100
    {
101
        return $this->client;
102
    }
103
104
    /**
105
     * @return Csv
106
     */
107
    public function csv(): Csv
108
    {
109
        return $this->csv;
110
    }
111
112
    /**
113
     * @return Users
114
     */
115
    public function users(): Users
116
    {
117
        return $this->users;
118
    }
119
120
    /**
121
     * @return Organizations
122
     */
123
    public function organizations(): Organizations
124
    {
125
        return $this->organizations;
126
    }
127
128
    /**
129
     * @return Titles
130
     */
131
    public function titles(): Titles
132
    {
133
        return $this->titles;
134
    }
135
136
    /**
137
     * @return Groups
138
     */
139
    public function groups(): Groups
140
    {
141
        return $this->groups;
142
    }
143
144
    /**
145
     * @return UserOrganizations
146
     */
147
    public function userOrganizations(): UserOrganizations
148
    {
149
        return $this->userOrganizations;
150
    }
151
152
    /**
153
     * @return UserGroups
154
     */
155
    public function userGroups(): UserGroups
156
    {
157
        return $this->userGroups;
158
    }
159
160
    /**
161
     * @return UserServices
162
     */
163
    public function userServices(): UserServices
164
    {
165
        return $this->userServices;
166
    }
167
168
    /**
169
     * @return OrganizationUsers
170
     */
171
    public function organizationUsers(): OrganizationUsers
172
    {
173
        return $this->organizationUsers;
174
    }
175
}
176