@@ -12,35 +12,35 @@ |
||
12 | 12 | class Client extends AbstractApi |
13 | 13 | { |
14 | 14 | |
15 | - /** Receiver constants */ |
|
16 | - const ACTIVITY = 'Activity'; |
|
17 | - const ENTERPRISE = 'Enterprise'; |
|
18 | - const GISTS = 'Gists'; |
|
19 | - const GIT_DATA = 'GitData'; |
|
20 | - const ISSUES = 'Issues'; |
|
21 | - const MISCELLANEOUS = 'Miscellaneous'; |
|
22 | - const ORGANIZATIONS = 'Organizations'; |
|
23 | - const PULL_REQUESTS = 'PullRequests'; |
|
24 | - const REPOSITORIES = 'Repositories'; |
|
25 | - const SEARCH = 'Search'; |
|
26 | - const USERS = 'Users'; |
|
15 | + /** Receiver constants */ |
|
16 | + const ACTIVITY = 'Activity'; |
|
17 | + const ENTERPRISE = 'Enterprise'; |
|
18 | + const GISTS = 'Gists'; |
|
19 | + const GIT_DATA = 'GitData'; |
|
20 | + const ISSUES = 'Issues'; |
|
21 | + const MISCELLANEOUS = 'Miscellaneous'; |
|
22 | + const ORGANIZATIONS = 'Organizations'; |
|
23 | + const PULL_REQUESTS = 'PullRequests'; |
|
24 | + const REPOSITORIES = 'Repositories'; |
|
25 | + const SEARCH = 'Search'; |
|
26 | + const USERS = 'Users'; |
|
27 | 27 | |
28 | - /** |
|
29 | - * Returns receiver object |
|
30 | - * |
|
31 | - * @param string $receiver |
|
32 | - * |
|
33 | - * @return null|AbstractReceiver |
|
34 | - */ |
|
35 | - public function getReceiver(string $receiver) |
|
36 | - { |
|
37 | - $class = (string)$this->sprintf(':namespace\Receiver\:receiver', __NAMESPACE__, $receiver); |
|
28 | + /** |
|
29 | + * Returns receiver object |
|
30 | + * |
|
31 | + * @param string $receiver |
|
32 | + * |
|
33 | + * @return null|AbstractReceiver |
|
34 | + */ |
|
35 | + public function getReceiver(string $receiver) |
|
36 | + { |
|
37 | + $class = (string)$this->sprintf(':namespace\Receiver\:receiver', __NAMESPACE__, $receiver); |
|
38 | 38 | |
39 | - if (class_exists($class)) { |
|
40 | - return new $class($this); |
|
41 | - } |
|
39 | + if (class_exists($class)) { |
|
40 | + return new $class($this); |
|
41 | + } |
|
42 | 42 | |
43 | - return null; |
|
44 | - } |
|
43 | + return null; |
|
44 | + } |
|
45 | 45 | |
46 | 46 | } |
47 | 47 | \ No newline at end of file |
@@ -11,110 +11,110 @@ |
||
11 | 11 | abstract class AbstractReceiver |
12 | 12 | { |
13 | 13 | |
14 | - /** Protected properties */ |
|
15 | - protected $api; |
|
16 | - protected $owner = ''; |
|
17 | - protected $repo = ''; |
|
18 | - |
|
19 | - /** |
|
20 | - * Constructor |
|
21 | - * |
|
22 | - * @param AbstractApi $api |
|
23 | - */ |
|
24 | - public function __construct(AbstractApi $api) |
|
25 | - { |
|
26 | - $this->setApi($api); |
|
27 | - } |
|
28 | - |
|
29 | - /** |
|
30 | - * Get api |
|
31 | - * |
|
32 | - * @return AbstractApi |
|
33 | - */ |
|
34 | - public function getApi(): AbstractApi |
|
35 | - { |
|
36 | - return $this->api; |
|
37 | - } |
|
38 | - |
|
39 | - /** |
|
40 | - * Set api |
|
41 | - * |
|
42 | - * @param AbstractApi $api |
|
43 | - * |
|
44 | - * @return AbstractReceiver |
|
45 | - */ |
|
46 | - public function setApi(AbstractApi $api): AbstractReceiver |
|
47 | - { |
|
48 | - $this->api = $api; |
|
49 | - |
|
50 | - return $this; |
|
51 | - } |
|
52 | - |
|
53 | - /** |
|
54 | - * Get owner |
|
55 | - * |
|
56 | - * @return string |
|
57 | - */ |
|
58 | - public function getOwner(): string |
|
59 | - { |
|
60 | - return $this->owner; |
|
61 | - } |
|
62 | - |
|
63 | - /** |
|
64 | - * Set owner |
|
65 | - * |
|
66 | - * @param string $owner |
|
67 | - * |
|
68 | - * @return AbstractReceiver |
|
69 | - */ |
|
70 | - public function setOwner(string $owner): AbstractReceiver |
|
71 | - { |
|
72 | - $this->owner = $owner; |
|
73 | - |
|
74 | - return $this; |
|
75 | - } |
|
76 | - |
|
77 | - /** |
|
78 | - * Get repository |
|
79 | - * |
|
80 | - * @return string |
|
81 | - */ |
|
82 | - public function getRepo(): string |
|
83 | - { |
|
84 | - return $this->repo; |
|
85 | - } |
|
86 | - |
|
87 | - /** |
|
88 | - * Set repository |
|
89 | - * |
|
90 | - * @param string $repo |
|
91 | - * |
|
92 | - * @return AbstractReceiver |
|
93 | - */ |
|
94 | - public function setRepo(string $repo): AbstractReceiver |
|
95 | - { |
|
96 | - $this->repo = $repo; |
|
97 | - |
|
98 | - return $this; |
|
99 | - } |
|
100 | - |
|
101 | - /** |
|
102 | - * Get a sub-receiver |
|
103 | - * |
|
104 | - * @param string $name |
|
105 | - * |
|
106 | - * @return null|object |
|
107 | - */ |
|
108 | - public function getReceiver(string $name) |
|
109 | - { |
|
110 | - $classPath = explode('\\', get_called_class()); |
|
111 | - $class = (string)$this->getApi() |
|
112 | - ->sprintf(':namespace\:class\:method', __NAMESPACE__, end($classPath), $name); |
|
113 | - |
|
114 | - if (class_exists($class)) { |
|
115 | - return new $class($this); |
|
116 | - } |
|
117 | - |
|
118 | - return null; |
|
119 | - } |
|
14 | + /** Protected properties */ |
|
15 | + protected $api; |
|
16 | + protected $owner = ''; |
|
17 | + protected $repo = ''; |
|
18 | + |
|
19 | + /** |
|
20 | + * Constructor |
|
21 | + * |
|
22 | + * @param AbstractApi $api |
|
23 | + */ |
|
24 | + public function __construct(AbstractApi $api) |
|
25 | + { |
|
26 | + $this->setApi($api); |
|
27 | + } |
|
28 | + |
|
29 | + /** |
|
30 | + * Get api |
|
31 | + * |
|
32 | + * @return AbstractApi |
|
33 | + */ |
|
34 | + public function getApi(): AbstractApi |
|
35 | + { |
|
36 | + return $this->api; |
|
37 | + } |
|
38 | + |
|
39 | + /** |
|
40 | + * Set api |
|
41 | + * |
|
42 | + * @param AbstractApi $api |
|
43 | + * |
|
44 | + * @return AbstractReceiver |
|
45 | + */ |
|
46 | + public function setApi(AbstractApi $api): AbstractReceiver |
|
47 | + { |
|
48 | + $this->api = $api; |
|
49 | + |
|
50 | + return $this; |
|
51 | + } |
|
52 | + |
|
53 | + /** |
|
54 | + * Get owner |
|
55 | + * |
|
56 | + * @return string |
|
57 | + */ |
|
58 | + public function getOwner(): string |
|
59 | + { |
|
60 | + return $this->owner; |
|
61 | + } |
|
62 | + |
|
63 | + /** |
|
64 | + * Set owner |
|
65 | + * |
|
66 | + * @param string $owner |
|
67 | + * |
|
68 | + * @return AbstractReceiver |
|
69 | + */ |
|
70 | + public function setOwner(string $owner): AbstractReceiver |
|
71 | + { |
|
72 | + $this->owner = $owner; |
|
73 | + |
|
74 | + return $this; |
|
75 | + } |
|
76 | + |
|
77 | + /** |
|
78 | + * Get repository |
|
79 | + * |
|
80 | + * @return string |
|
81 | + */ |
|
82 | + public function getRepo(): string |
|
83 | + { |
|
84 | + return $this->repo; |
|
85 | + } |
|
86 | + |
|
87 | + /** |
|
88 | + * Set repository |
|
89 | + * |
|
90 | + * @param string $repo |
|
91 | + * |
|
92 | + * @return AbstractReceiver |
|
93 | + */ |
|
94 | + public function setRepo(string $repo): AbstractReceiver |
|
95 | + { |
|
96 | + $this->repo = $repo; |
|
97 | + |
|
98 | + return $this; |
|
99 | + } |
|
100 | + |
|
101 | + /** |
|
102 | + * Get a sub-receiver |
|
103 | + * |
|
104 | + * @param string $name |
|
105 | + * |
|
106 | + * @return null|object |
|
107 | + */ |
|
108 | + public function getReceiver(string $name) |
|
109 | + { |
|
110 | + $classPath = explode('\\', get_called_class()); |
|
111 | + $class = (string)$this->getApi() |
|
112 | + ->sprintf(':namespace\:class\:method', __NAMESPACE__, end($classPath), $name); |
|
113 | + |
|
114 | + if (class_exists($class)) { |
|
115 | + return new $class($this); |
|
116 | + } |
|
117 | + |
|
118 | + return null; |
|
119 | + } |
|
120 | 120 | } |
121 | 121 | \ No newline at end of file |
@@ -12,81 +12,81 @@ |
||
12 | 12 | class Users extends AbstractReceiver |
13 | 13 | { |
14 | 14 | |
15 | - /** Available sub-Receiver */ |
|
16 | - const EMAILS = 'Emails'; |
|
17 | - const FOLLOWERS = 'Followers'; |
|
18 | - const PUBLIC_KEYS = 'PublicKeys'; |
|
15 | + /** Available sub-Receiver */ |
|
16 | + const EMAILS = 'Emails'; |
|
17 | + const FOLLOWERS = 'Followers'; |
|
18 | + const PUBLIC_KEYS = 'PublicKeys'; |
|
19 | 19 | |
20 | - /** |
|
21 | - * Get a single user |
|
22 | - * |
|
23 | - * @link https://developer.github.com/v3/users/#get-a-single-user |
|
24 | - * |
|
25 | - * @param string $username |
|
26 | - * |
|
27 | - * @return array |
|
28 | - * @throws \Exception |
|
29 | - */ |
|
30 | - public function getSingleUser(string $username): array |
|
31 | - { |
|
32 | - return $this->getApi()->request($this->getApi()->sprintf('/users/:username', $username)); |
|
33 | - } |
|
20 | + /** |
|
21 | + * Get a single user |
|
22 | + * |
|
23 | + * @link https://developer.github.com/v3/users/#get-a-single-user |
|
24 | + * |
|
25 | + * @param string $username |
|
26 | + * |
|
27 | + * @return array |
|
28 | + * @throws \Exception |
|
29 | + */ |
|
30 | + public function getSingleUser(string $username): array |
|
31 | + { |
|
32 | + return $this->getApi()->request($this->getApi()->sprintf('/users/:username', $username)); |
|
33 | + } |
|
34 | 34 | |
35 | - /** |
|
36 | - * Get the authenticated user |
|
37 | - * |
|
38 | - * @link https://developer.github.com/v3/users/#get-the-authenticated-user |
|
39 | - * @return array |
|
40 | - * @throws \Exception |
|
41 | - */ |
|
42 | - public function getUser(): array |
|
43 | - { |
|
44 | - return $this->getApi()->request($this->getApi()->sprintf('/user')); |
|
45 | - } |
|
35 | + /** |
|
36 | + * Get the authenticated user |
|
37 | + * |
|
38 | + * @link https://developer.github.com/v3/users/#get-the-authenticated-user |
|
39 | + * @return array |
|
40 | + * @throws \Exception |
|
41 | + */ |
|
42 | + public function getUser(): array |
|
43 | + { |
|
44 | + return $this->getApi()->request($this->getApi()->sprintf('/user')); |
|
45 | + } |
|
46 | 46 | |
47 | - /** |
|
48 | - * Update the authenticated user |
|
49 | - * |
|
50 | - * @link https://developer.github.com/v3/users/#update-the-authenticated-user |
|
51 | - * |
|
52 | - * @param string $name |
|
53 | - * @param string $email |
|
54 | - * @param string $blog |
|
55 | - * @param string $company |
|
56 | - * @param string $location |
|
57 | - * @param bool $hireable |
|
58 | - * @param string $bio |
|
59 | - * |
|
60 | - * @return array |
|
61 | - * @throws \Exception |
|
62 | - */ |
|
63 | - public function updateUser(string $name = null, string $email = null, string $blog = null, string $company = null, |
|
64 | - string $location = null, bool $hireable = false, string $bio = null): array |
|
65 | - { |
|
66 | - return $this->getApi()->request($this->getApi()->sprintf('/user'), Request::METHOD_PATCH, [ |
|
67 | - 'name' => $name, |
|
68 | - 'email' => $email, |
|
69 | - 'blog' => $blog, |
|
70 | - 'company' => $company, |
|
71 | - 'location' => $location, |
|
72 | - 'hireable' => $hireable, |
|
73 | - 'bio' => $bio |
|
74 | - ]); |
|
75 | - } |
|
47 | + /** |
|
48 | + * Update the authenticated user |
|
49 | + * |
|
50 | + * @link https://developer.github.com/v3/users/#update-the-authenticated-user |
|
51 | + * |
|
52 | + * @param string $name |
|
53 | + * @param string $email |
|
54 | + * @param string $blog |
|
55 | + * @param string $company |
|
56 | + * @param string $location |
|
57 | + * @param bool $hireable |
|
58 | + * @param string $bio |
|
59 | + * |
|
60 | + * @return array |
|
61 | + * @throws \Exception |
|
62 | + */ |
|
63 | + public function updateUser(string $name = null, string $email = null, string $blog = null, string $company = null, |
|
64 | + string $location = null, bool $hireable = false, string $bio = null): array |
|
65 | + { |
|
66 | + return $this->getApi()->request($this->getApi()->sprintf('/user'), Request::METHOD_PATCH, [ |
|
67 | + 'name' => $name, |
|
68 | + 'email' => $email, |
|
69 | + 'blog' => $blog, |
|
70 | + 'company' => $company, |
|
71 | + 'location' => $location, |
|
72 | + 'hireable' => $hireable, |
|
73 | + 'bio' => $bio |
|
74 | + ]); |
|
75 | + } |
|
76 | 76 | |
77 | - /** |
|
78 | - * Get all users |
|
79 | - * |
|
80 | - * @link https://developer.github.com/v3/users/#get-all-users |
|
81 | - * |
|
82 | - * @param string $since |
|
83 | - * |
|
84 | - * @return array |
|
85 | - * @throws \Exception |
|
86 | - */ |
|
87 | - public function getAllUsers(string $since = null): array |
|
88 | - { |
|
89 | - return $this->getApi()->request($this->getApi() |
|
90 | - ->sprintf('/users?:args', http_build_query(['since' => $since]))); |
|
91 | - } |
|
77 | + /** |
|
78 | + * Get all users |
|
79 | + * |
|
80 | + * @link https://developer.github.com/v3/users/#get-all-users |
|
81 | + * |
|
82 | + * @param string $since |
|
83 | + * |
|
84 | + * @return array |
|
85 | + * @throws \Exception |
|
86 | + */ |
|
87 | + public function getAllUsers(string $since = null): array |
|
88 | + { |
|
89 | + return $this->getApi()->request($this->getApi() |
|
90 | + ->sprintf('/users?:args', http_build_query(['since' => $since]))); |
|
91 | + } |
|
92 | 92 | } |
93 | 93 | \ No newline at end of file |
@@ -12,83 +12,83 @@ |
||
12 | 12 | class Search extends AbstractReceiver |
13 | 13 | { |
14 | 14 | |
15 | - /** Available sub-Receiver */ |
|
16 | - const REPOSITORIES = 'Repositories'; |
|
17 | - const CODE = 'Code'; |
|
18 | - const ISSUES = 'Issues'; |
|
19 | - const USERS = 'Users'; |
|
20 | - const LEGACY_SEARCH = 'LegacySearch'; |
|
15 | + /** Available sub-Receiver */ |
|
16 | + const REPOSITORIES = 'Repositories'; |
|
17 | + const CODE = 'Code'; |
|
18 | + const ISSUES = 'Issues'; |
|
19 | + const USERS = 'Users'; |
|
20 | + const LEGACY_SEARCH = 'LegacySearch'; |
|
21 | 21 | |
22 | - /** |
|
23 | - * Search repositories |
|
24 | - * |
|
25 | - * @link https://developer.github.com/v3/search/#search-repositories |
|
26 | - * |
|
27 | - * @param string $q |
|
28 | - * @param string $sort |
|
29 | - * @param string $order |
|
30 | - * |
|
31 | - * @return array |
|
32 | - * @throws \Exception |
|
33 | - */ |
|
34 | - public function searchRepositories(string $q, string $sort = null, |
|
35 | - string $order = AbstractApi::DIRECTION_DESC): array |
|
36 | - { |
|
37 | - return $this->getApi()->request($this->getApi()->sprintf('/search/repositories?:args', |
|
38 | - http_build_query(['q' => $q, 'sort' => $sort, 'order' => $order]))); |
|
39 | - } |
|
22 | + /** |
|
23 | + * Search repositories |
|
24 | + * |
|
25 | + * @link https://developer.github.com/v3/search/#search-repositories |
|
26 | + * |
|
27 | + * @param string $q |
|
28 | + * @param string $sort |
|
29 | + * @param string $order |
|
30 | + * |
|
31 | + * @return array |
|
32 | + * @throws \Exception |
|
33 | + */ |
|
34 | + public function searchRepositories(string $q, string $sort = null, |
|
35 | + string $order = AbstractApi::DIRECTION_DESC): array |
|
36 | + { |
|
37 | + return $this->getApi()->request($this->getApi()->sprintf('/search/repositories?:args', |
|
38 | + http_build_query(['q' => $q, 'sort' => $sort, 'order' => $order]))); |
|
39 | + } |
|
40 | 40 | |
41 | - /** |
|
42 | - * Search code |
|
43 | - * |
|
44 | - * @link https://developer.github.com/v3/search/#search-code |
|
45 | - * |
|
46 | - * @param string $q |
|
47 | - * @param string $sort |
|
48 | - * @param string $order |
|
49 | - * |
|
50 | - * @return array |
|
51 | - * @throws \Exception |
|
52 | - */ |
|
53 | - public function searchCode(string $q, string $sort = null, string $order = AbstractApi::DIRECTION_DESC): array |
|
54 | - { |
|
55 | - return $this->getApi()->request($this->getApi()->sprintf('/search/code?:args', |
|
56 | - http_build_query(['q' => $q, 'sort' => $sort, 'order' => $order]))); |
|
57 | - } |
|
41 | + /** |
|
42 | + * Search code |
|
43 | + * |
|
44 | + * @link https://developer.github.com/v3/search/#search-code |
|
45 | + * |
|
46 | + * @param string $q |
|
47 | + * @param string $sort |
|
48 | + * @param string $order |
|
49 | + * |
|
50 | + * @return array |
|
51 | + * @throws \Exception |
|
52 | + */ |
|
53 | + public function searchCode(string $q, string $sort = null, string $order = AbstractApi::DIRECTION_DESC): array |
|
54 | + { |
|
55 | + return $this->getApi()->request($this->getApi()->sprintf('/search/code?:args', |
|
56 | + http_build_query(['q' => $q, 'sort' => $sort, 'order' => $order]))); |
|
57 | + } |
|
58 | 58 | |
59 | - /** |
|
60 | - * Search issues |
|
61 | - * |
|
62 | - * @link https://developer.github.com/v3/search/#search-issues |
|
63 | - * |
|
64 | - * @param string $q |
|
65 | - * @param string $sort |
|
66 | - * @param string $order |
|
67 | - * |
|
68 | - * @return array |
|
69 | - * @throws \Exception |
|
70 | - */ |
|
71 | - public function searchIssues(string $q, string $sort = null, string $order = AbstractApi::DIRECTION_DESC): array |
|
72 | - { |
|
73 | - return $this->getApi()->request($this->getApi()->sprintf('/search/issues?:args', |
|
74 | - http_build_query(['q' => $q, 'sort' => $sort, 'order' => $order]))); |
|
75 | - } |
|
59 | + /** |
|
60 | + * Search issues |
|
61 | + * |
|
62 | + * @link https://developer.github.com/v3/search/#search-issues |
|
63 | + * |
|
64 | + * @param string $q |
|
65 | + * @param string $sort |
|
66 | + * @param string $order |
|
67 | + * |
|
68 | + * @return array |
|
69 | + * @throws \Exception |
|
70 | + */ |
|
71 | + public function searchIssues(string $q, string $sort = null, string $order = AbstractApi::DIRECTION_DESC): array |
|
72 | + { |
|
73 | + return $this->getApi()->request($this->getApi()->sprintf('/search/issues?:args', |
|
74 | + http_build_query(['q' => $q, 'sort' => $sort, 'order' => $order]))); |
|
75 | + } |
|
76 | 76 | |
77 | - /** |
|
78 | - * Search users |
|
79 | - * |
|
80 | - * @link https://developer.github.com/v3/search/#search-users |
|
81 | - * |
|
82 | - * @param string $q |
|
83 | - * @param string $sort |
|
84 | - * @param string $order |
|
85 | - * |
|
86 | - * @return array |
|
87 | - * @throws \Exception |
|
88 | - */ |
|
89 | - public function searchUsers(string $q, string $sort = null, string $order = AbstractApi::DIRECTION_DESC): array |
|
90 | - { |
|
91 | - return $this->getApi()->request($this->getApi()->sprintf('/search/users?:args', |
|
92 | - http_build_query(['q' => $q, 'sort' => $sort, 'order' => $order]))); |
|
93 | - } |
|
77 | + /** |
|
78 | + * Search users |
|
79 | + * |
|
80 | + * @link https://developer.github.com/v3/search/#search-users |
|
81 | + * |
|
82 | + * @param string $q |
|
83 | + * @param string $sort |
|
84 | + * @param string $order |
|
85 | + * |
|
86 | + * @return array |
|
87 | + * @throws \Exception |
|
88 | + */ |
|
89 | + public function searchUsers(string $q, string $sort = null, string $order = AbstractApi::DIRECTION_DESC): array |
|
90 | + { |
|
91 | + return $this->getApi()->request($this->getApi()->sprintf('/search/users?:args', |
|
92 | + http_build_query(['q' => $q, 'sort' => $sort, 'order' => $order]))); |
|
93 | + } |
|
94 | 94 | } |
95 | 95 | \ No newline at end of file |
@@ -12,10 +12,10 @@ |
||
12 | 12 | class Enterprise extends AbstractReceiver |
13 | 13 | { |
14 | 14 | |
15 | - /** Available sub-Receiver */ |
|
16 | - const ADMIN_STATS = 'AdminStats'; |
|
17 | - const LDAP = 'Ldap'; |
|
18 | - const LICENSE = 'License'; |
|
19 | - const MANAGEMENT_CONSOLE = 'ManagementConsole'; |
|
20 | - const SEARCH_INDEXING = 'SearchIndexing'; |
|
15 | + /** Available sub-Receiver */ |
|
16 | + const ADMIN_STATS = 'AdminStats'; |
|
17 | + const LDAP = 'Ldap'; |
|
18 | + const LICENSE = 'License'; |
|
19 | + const MANAGEMENT_CONSOLE = 'ManagementConsole'; |
|
20 | + const SEARCH_INDEXING = 'SearchIndexing'; |
|
21 | 21 | } |
22 | 22 | \ No newline at end of file |
@@ -12,66 +12,66 @@ |
||
12 | 12 | abstract class AbstractUsers |
13 | 13 | { |
14 | 14 | |
15 | - /** Properties */ |
|
16 | - protected $users; |
|
17 | - protected $api; |
|
15 | + /** Properties */ |
|
16 | + protected $users; |
|
17 | + protected $api; |
|
18 | 18 | |
19 | - /** |
|
20 | - * Constructor |
|
21 | - * |
|
22 | - * @param Users $users |
|
23 | - */ |
|
24 | - public function __construct(Users $users) |
|
25 | - { |
|
26 | - $this->setUsers($users); |
|
27 | - $this->setApi($users->getApi()); |
|
28 | - } |
|
19 | + /** |
|
20 | + * Constructor |
|
21 | + * |
|
22 | + * @param Users $users |
|
23 | + */ |
|
24 | + public function __construct(Users $users) |
|
25 | + { |
|
26 | + $this->setUsers($users); |
|
27 | + $this->setApi($users->getApi()); |
|
28 | + } |
|
29 | 29 | |
30 | - /** |
|
31 | - * Get users |
|
32 | - * |
|
33 | - * @return Users |
|
34 | - */ |
|
35 | - public function getUsers(): Users |
|
36 | - { |
|
37 | - return $this->users; |
|
38 | - } |
|
30 | + /** |
|
31 | + * Get users |
|
32 | + * |
|
33 | + * @return Users |
|
34 | + */ |
|
35 | + public function getUsers(): Users |
|
36 | + { |
|
37 | + return $this->users; |
|
38 | + } |
|
39 | 39 | |
40 | - /** |
|
41 | - * Set users |
|
42 | - * |
|
43 | - * @param Users $users |
|
44 | - * |
|
45 | - * @return AbstractUsers |
|
46 | - */ |
|
47 | - public function setUsers(Users $users): AbstractUsers |
|
48 | - { |
|
49 | - $this->users = $users; |
|
40 | + /** |
|
41 | + * Set users |
|
42 | + * |
|
43 | + * @param Users $users |
|
44 | + * |
|
45 | + * @return AbstractUsers |
|
46 | + */ |
|
47 | + public function setUsers(Users $users): AbstractUsers |
|
48 | + { |
|
49 | + $this->users = $users; |
|
50 | 50 | |
51 | - return $this; |
|
52 | - } |
|
51 | + return $this; |
|
52 | + } |
|
53 | 53 | |
54 | - /** |
|
55 | - * Get api |
|
56 | - * |
|
57 | - * @return AbstractApi |
|
58 | - */ |
|
59 | - public function getApi(): AbstractApi |
|
60 | - { |
|
61 | - return $this->api; |
|
62 | - } |
|
54 | + /** |
|
55 | + * Get api |
|
56 | + * |
|
57 | + * @return AbstractApi |
|
58 | + */ |
|
59 | + public function getApi(): AbstractApi |
|
60 | + { |
|
61 | + return $this->api; |
|
62 | + } |
|
63 | 63 | |
64 | - /** |
|
65 | - * Set api |
|
66 | - * |
|
67 | - * @param AbstractApi $api |
|
68 | - * |
|
69 | - * @return AbstractUsers |
|
70 | - */ |
|
71 | - public function setApi(AbstractApi $api): AbstractUsers |
|
72 | - { |
|
73 | - $this->api = $api; |
|
64 | + /** |
|
65 | + * Set api |
|
66 | + * |
|
67 | + * @param AbstractApi $api |
|
68 | + * |
|
69 | + * @return AbstractUsers |
|
70 | + */ |
|
71 | + public function setApi(AbstractApi $api): AbstractUsers |
|
72 | + { |
|
73 | + $this->api = $api; |
|
74 | 74 | |
75 | - return $this; |
|
76 | - } |
|
75 | + return $this; |
|
76 | + } |
|
77 | 77 | } |
78 | 78 | \ No newline at end of file |
@@ -12,130 +12,130 @@ |
||
12 | 12 | class Followers extends AbstractUsers |
13 | 13 | { |
14 | 14 | |
15 | - /** |
|
16 | - * List followers of a user |
|
17 | - * |
|
18 | - * @link https://developer.github.com/v3/users/followers/#list-followers-of-a-user |
|
19 | - * |
|
20 | - * @param null|string $username |
|
21 | - * |
|
22 | - * @return array |
|
23 | - * @throws \Exception |
|
24 | - */ |
|
25 | - public function listFollowers(string $username = null): array |
|
26 | - { |
|
27 | - $url = '/user/followers'; |
|
28 | - if (null !== $username) { |
|
29 | - $url = $this->getApi()->sprintf('/users/:username/followers', $username); |
|
30 | - } |
|
31 | - |
|
32 | - return $this->getApi()->request($url); |
|
33 | - } |
|
34 | - |
|
35 | - /** |
|
36 | - * List users followed by another user |
|
37 | - * |
|
38 | - * @link https://developer.github.com/v3/users/followers/#list-users-followed-by-another-user |
|
39 | - * |
|
40 | - * @param null|string $username |
|
41 | - * |
|
42 | - * @return array |
|
43 | - * @throws \Exception |
|
44 | - */ |
|
45 | - public function listUsersFollowedBy(string $username = null): array |
|
46 | - { |
|
47 | - $url = '/user/following'; |
|
48 | - if (null !== $username) { |
|
49 | - $url = $this->getApi()->sprintf('/users/:username/following', $username); |
|
50 | - } |
|
51 | - |
|
52 | - return $this->getApi()->request($url); |
|
53 | - } |
|
54 | - |
|
55 | - /** |
|
56 | - * Check if you are following a user |
|
57 | - * |
|
58 | - * @link https://developer.github.com/v3/users/followers/#check-if-you-are-following-a-user |
|
59 | - * |
|
60 | - * @param string $username |
|
61 | - * |
|
62 | - * @return bool |
|
63 | - * @throws \Exception |
|
64 | - */ |
|
65 | - public function checkFollowingUser(string $username): bool |
|
66 | - { |
|
67 | - $this->getApi()->request($this->getApi()->sprintf('/user/following/:username', $username)); |
|
68 | - |
|
69 | - if ($this->getApi()->getHeaders()['Status'] == '204 No Content') { |
|
70 | - return true; |
|
71 | - } |
|
72 | - |
|
73 | - return false; |
|
74 | - } |
|
75 | - |
|
76 | - /** |
|
77 | - * Check if one user follows another |
|
78 | - * |
|
79 | - * @link https://developer.github.com/v3/users/followers/#check-if-one-user-follows-another |
|
80 | - * |
|
81 | - * @param string $username |
|
82 | - * @param string $targetUser |
|
83 | - * |
|
84 | - * @return bool |
|
85 | - * @throws \Exception |
|
86 | - */ |
|
87 | - public function checkUserFollowsAnother(string $username, string $targetUser): bool |
|
88 | - { |
|
89 | - $this->getApi()->request($this->getApi() |
|
90 | - ->sprintf('/users/:username/following/:target_user', $username, $targetUser)); |
|
91 | - |
|
92 | - if ($this->getApi()->getHeaders()['Status'] == '204 No Content') { |
|
93 | - return true; |
|
94 | - } |
|
95 | - |
|
96 | - return false; |
|
97 | - } |
|
98 | - |
|
99 | - /** |
|
100 | - * Follow a user |
|
101 | - * |
|
102 | - * @link https://developer.github.com/v3/users/followers/#follow-a-user |
|
103 | - * |
|
104 | - * @param string $username |
|
105 | - * |
|
106 | - * @return bool |
|
107 | - * @throws \Exception |
|
108 | - */ |
|
109 | - public function followUser(string $username): bool |
|
110 | - { |
|
111 | - $this->getApi()->request($this->getApi()->sprintf('/user/following/:username', $username), Request::METHOD_PUT); |
|
112 | - |
|
113 | - if ($this->getApi()->getHeaders()['Status'] == '204 No Content') { |
|
114 | - return true; |
|
115 | - } |
|
116 | - |
|
117 | - return false; |
|
118 | - } |
|
119 | - |
|
120 | - /** |
|
121 | - * Unfollow a user |
|
122 | - * |
|
123 | - * @link https://developer.github.com/v3/users/followers/#unfollow-a-user |
|
124 | - * |
|
125 | - * @param string $username |
|
126 | - * |
|
127 | - * @return bool |
|
128 | - * @throws \Exception |
|
129 | - */ |
|
130 | - public function unfollowUser(string $username): bool |
|
131 | - { |
|
132 | - $this->getApi()->request($this->getApi()->sprintf('/user/following/:username', $username), |
|
133 | - Request::METHOD_DELETE); |
|
134 | - |
|
135 | - if ($this->getApi()->getHeaders()['Status'] == '204 No Content') { |
|
136 | - return true; |
|
137 | - } |
|
138 | - |
|
139 | - return false; |
|
140 | - } |
|
15 | + /** |
|
16 | + * List followers of a user |
|
17 | + * |
|
18 | + * @link https://developer.github.com/v3/users/followers/#list-followers-of-a-user |
|
19 | + * |
|
20 | + * @param null|string $username |
|
21 | + * |
|
22 | + * @return array |
|
23 | + * @throws \Exception |
|
24 | + */ |
|
25 | + public function listFollowers(string $username = null): array |
|
26 | + { |
|
27 | + $url = '/user/followers'; |
|
28 | + if (null !== $username) { |
|
29 | + $url = $this->getApi()->sprintf('/users/:username/followers', $username); |
|
30 | + } |
|
31 | + |
|
32 | + return $this->getApi()->request($url); |
|
33 | + } |
|
34 | + |
|
35 | + /** |
|
36 | + * List users followed by another user |
|
37 | + * |
|
38 | + * @link https://developer.github.com/v3/users/followers/#list-users-followed-by-another-user |
|
39 | + * |
|
40 | + * @param null|string $username |
|
41 | + * |
|
42 | + * @return array |
|
43 | + * @throws \Exception |
|
44 | + */ |
|
45 | + public function listUsersFollowedBy(string $username = null): array |
|
46 | + { |
|
47 | + $url = '/user/following'; |
|
48 | + if (null !== $username) { |
|
49 | + $url = $this->getApi()->sprintf('/users/:username/following', $username); |
|
50 | + } |
|
51 | + |
|
52 | + return $this->getApi()->request($url); |
|
53 | + } |
|
54 | + |
|
55 | + /** |
|
56 | + * Check if you are following a user |
|
57 | + * |
|
58 | + * @link https://developer.github.com/v3/users/followers/#check-if-you-are-following-a-user |
|
59 | + * |
|
60 | + * @param string $username |
|
61 | + * |
|
62 | + * @return bool |
|
63 | + * @throws \Exception |
|
64 | + */ |
|
65 | + public function checkFollowingUser(string $username): bool |
|
66 | + { |
|
67 | + $this->getApi()->request($this->getApi()->sprintf('/user/following/:username', $username)); |
|
68 | + |
|
69 | + if ($this->getApi()->getHeaders()['Status'] == '204 No Content') { |
|
70 | + return true; |
|
71 | + } |
|
72 | + |
|
73 | + return false; |
|
74 | + } |
|
75 | + |
|
76 | + /** |
|
77 | + * Check if one user follows another |
|
78 | + * |
|
79 | + * @link https://developer.github.com/v3/users/followers/#check-if-one-user-follows-another |
|
80 | + * |
|
81 | + * @param string $username |
|
82 | + * @param string $targetUser |
|
83 | + * |
|
84 | + * @return bool |
|
85 | + * @throws \Exception |
|
86 | + */ |
|
87 | + public function checkUserFollowsAnother(string $username, string $targetUser): bool |
|
88 | + { |
|
89 | + $this->getApi()->request($this->getApi() |
|
90 | + ->sprintf('/users/:username/following/:target_user', $username, $targetUser)); |
|
91 | + |
|
92 | + if ($this->getApi()->getHeaders()['Status'] == '204 No Content') { |
|
93 | + return true; |
|
94 | + } |
|
95 | + |
|
96 | + return false; |
|
97 | + } |
|
98 | + |
|
99 | + /** |
|
100 | + * Follow a user |
|
101 | + * |
|
102 | + * @link https://developer.github.com/v3/users/followers/#follow-a-user |
|
103 | + * |
|
104 | + * @param string $username |
|
105 | + * |
|
106 | + * @return bool |
|
107 | + * @throws \Exception |
|
108 | + */ |
|
109 | + public function followUser(string $username): bool |
|
110 | + { |
|
111 | + $this->getApi()->request($this->getApi()->sprintf('/user/following/:username', $username), Request::METHOD_PUT); |
|
112 | + |
|
113 | + if ($this->getApi()->getHeaders()['Status'] == '204 No Content') { |
|
114 | + return true; |
|
115 | + } |
|
116 | + |
|
117 | + return false; |
|
118 | + } |
|
119 | + |
|
120 | + /** |
|
121 | + * Unfollow a user |
|
122 | + * |
|
123 | + * @link https://developer.github.com/v3/users/followers/#unfollow-a-user |
|
124 | + * |
|
125 | + * @param string $username |
|
126 | + * |
|
127 | + * @return bool |
|
128 | + * @throws \Exception |
|
129 | + */ |
|
130 | + public function unfollowUser(string $username): bool |
|
131 | + { |
|
132 | + $this->getApi()->request($this->getApi()->sprintf('/user/following/:username', $username), |
|
133 | + Request::METHOD_DELETE); |
|
134 | + |
|
135 | + if ($this->getApi()->getHeaders()['Status'] == '204 No Content') { |
|
136 | + return true; |
|
137 | + } |
|
138 | + |
|
139 | + return false; |
|
140 | + } |
|
141 | 141 | } |
142 | 142 | \ No newline at end of file |
@@ -12,51 +12,51 @@ |
||
12 | 12 | class Emails extends AbstractUsers |
13 | 13 | { |
14 | 14 | |
15 | - /** |
|
16 | - * List email addresses for a user |
|
17 | - * |
|
18 | - * @link https://developer.github.com/v3/users/emails/#list-email-addresses-for-a-user |
|
19 | - * @return array |
|
20 | - * @throws \Exception |
|
21 | - */ |
|
22 | - public function listEmailAddresses(): array |
|
23 | - { |
|
24 | - return $this->getApi()->request($this->getApi()->sprintf('/user/emails')); |
|
25 | - } |
|
15 | + /** |
|
16 | + * List email addresses for a user |
|
17 | + * |
|
18 | + * @link https://developer.github.com/v3/users/emails/#list-email-addresses-for-a-user |
|
19 | + * @return array |
|
20 | + * @throws \Exception |
|
21 | + */ |
|
22 | + public function listEmailAddresses(): array |
|
23 | + { |
|
24 | + return $this->getApi()->request($this->getApi()->sprintf('/user/emails')); |
|
25 | + } |
|
26 | 26 | |
27 | - /** |
|
28 | - * Add email address(es) |
|
29 | - * |
|
30 | - * @link https://developer.github.com/v3/users/emails/#add-email-addresses |
|
31 | - * |
|
32 | - * @param array $addresses |
|
33 | - * |
|
34 | - * @return array |
|
35 | - * @throws \Exception |
|
36 | - */ |
|
37 | - public function addEmailAddress(array $addresses = []): array |
|
38 | - { |
|
39 | - return $this->getApi()->request($this->getApi()->sprintf('/user/emails'), Request::METHOD_POST, $addresses); |
|
40 | - } |
|
27 | + /** |
|
28 | + * Add email address(es) |
|
29 | + * |
|
30 | + * @link https://developer.github.com/v3/users/emails/#add-email-addresses |
|
31 | + * |
|
32 | + * @param array $addresses |
|
33 | + * |
|
34 | + * @return array |
|
35 | + * @throws \Exception |
|
36 | + */ |
|
37 | + public function addEmailAddress(array $addresses = []): array |
|
38 | + { |
|
39 | + return $this->getApi()->request($this->getApi()->sprintf('/user/emails'), Request::METHOD_POST, $addresses); |
|
40 | + } |
|
41 | 41 | |
42 | - /** |
|
43 | - * Delete email address(es) |
|
44 | - * |
|
45 | - * @link https://developer.github.com/v3/users/emails/#delete-email-addresses |
|
46 | - * |
|
47 | - * @param array $addresses |
|
48 | - * |
|
49 | - * @return bool |
|
50 | - * @throws \Exception |
|
51 | - */ |
|
52 | - public function deleteEmailAddress(array $addresses = []): bool |
|
53 | - { |
|
54 | - $this->getApi()->request($this->getApi()->sprintf('/user/emails'), Request::METHOD_DELETE, $addresses); |
|
42 | + /** |
|
43 | + * Delete email address(es) |
|
44 | + * |
|
45 | + * @link https://developer.github.com/v3/users/emails/#delete-email-addresses |
|
46 | + * |
|
47 | + * @param array $addresses |
|
48 | + * |
|
49 | + * @return bool |
|
50 | + * @throws \Exception |
|
51 | + */ |
|
52 | + public function deleteEmailAddress(array $addresses = []): bool |
|
53 | + { |
|
54 | + $this->getApi()->request($this->getApi()->sprintf('/user/emails'), Request::METHOD_DELETE, $addresses); |
|
55 | 55 | |
56 | - if ($this->getApi()->getHeaders()['Status'] == '204 No Content') { |
|
57 | - return true; |
|
58 | - } |
|
56 | + if ($this->getApi()->getHeaders()['Status'] == '204 No Content') { |
|
57 | + return true; |
|
58 | + } |
|
59 | 59 | |
60 | - return false; |
|
61 | - } |
|
60 | + return false; |
|
61 | + } |
|
62 | 62 | } |
63 | 63 | \ No newline at end of file |
@@ -12,73 +12,73 @@ |
||
12 | 12 | class PublicKeys extends AbstractUsers |
13 | 13 | { |
14 | 14 | |
15 | - /** |
|
16 | - * List public keys for a user |
|
17 | - * |
|
18 | - * @link https://developer.github.com/v3/users/keys/#list-public-keys-for-a-user |
|
19 | - * |
|
20 | - * @param string $username |
|
21 | - * |
|
22 | - * @return array |
|
23 | - * @throws \Exception |
|
24 | - */ |
|
25 | - public function listUserPublicKeys(string $username): array |
|
26 | - { |
|
27 | - return $this->getApi()->request($this->getApi()->sprintf('/users/:username/keys', $username)); |
|
28 | - } |
|
15 | + /** |
|
16 | + * List public keys for a user |
|
17 | + * |
|
18 | + * @link https://developer.github.com/v3/users/keys/#list-public-keys-for-a-user |
|
19 | + * |
|
20 | + * @param string $username |
|
21 | + * |
|
22 | + * @return array |
|
23 | + * @throws \Exception |
|
24 | + */ |
|
25 | + public function listUserPublicKeys(string $username): array |
|
26 | + { |
|
27 | + return $this->getApi()->request($this->getApi()->sprintf('/users/:username/keys', $username)); |
|
28 | + } |
|
29 | 29 | |
30 | - /** |
|
31 | - * List your public keys |
|
32 | - * |
|
33 | - * @link https://developer.github.com/v3/users/keys/#list-your-public-keys |
|
34 | - * @return array |
|
35 | - * @throws \Exception |
|
36 | - */ |
|
37 | - public function listYourPublicKeys(): array |
|
38 | - { |
|
39 | - return $this->getApi()->request($this->getApi()->sprintf('/user/keys')); |
|
40 | - } |
|
30 | + /** |
|
31 | + * List your public keys |
|
32 | + * |
|
33 | + * @link https://developer.github.com/v3/users/keys/#list-your-public-keys |
|
34 | + * @return array |
|
35 | + * @throws \Exception |
|
36 | + */ |
|
37 | + public function listYourPublicKeys(): array |
|
38 | + { |
|
39 | + return $this->getApi()->request($this->getApi()->sprintf('/user/keys')); |
|
40 | + } |
|
41 | 41 | |
42 | - /** |
|
43 | - * Get a single public key |
|
44 | - * |
|
45 | - * @link https://developer.github.com/v3/users/keys/#get-a-single-public-key |
|
46 | - * |
|
47 | - * @param int $id |
|
48 | - * |
|
49 | - * @return array |
|
50 | - * @throws \Exception |
|
51 | - */ |
|
52 | - public function getSinglePublicKey(int $id): array |
|
53 | - { |
|
54 | - return $this->getApi()->request($this->getApi()->sprintf('/user/keys/:id', (string)$id)); |
|
55 | - } |
|
42 | + /** |
|
43 | + * Get a single public key |
|
44 | + * |
|
45 | + * @link https://developer.github.com/v3/users/keys/#get-a-single-public-key |
|
46 | + * |
|
47 | + * @param int $id |
|
48 | + * |
|
49 | + * @return array |
|
50 | + * @throws \Exception |
|
51 | + */ |
|
52 | + public function getSinglePublicKey(int $id): array |
|
53 | + { |
|
54 | + return $this->getApi()->request($this->getApi()->sprintf('/user/keys/:id', (string)$id)); |
|
55 | + } |
|
56 | 56 | |
57 | - /** |
|
58 | - * Create a public key |
|
59 | - * |
|
60 | - * @link https://developer.github.com/v3/users/keys/#create-a-public-key |
|
61 | - * @return array |
|
62 | - * @throws \Exception |
|
63 | - */ |
|
64 | - public function createPublicKey(): array |
|
65 | - { |
|
66 | - return $this->getApi()->request($this->getApi()->sprintf('/user/keys'), Request::METHOD_POST); |
|
67 | - } |
|
57 | + /** |
|
58 | + * Create a public key |
|
59 | + * |
|
60 | + * @link https://developer.github.com/v3/users/keys/#create-a-public-key |
|
61 | + * @return array |
|
62 | + * @throws \Exception |
|
63 | + */ |
|
64 | + public function createPublicKey(): array |
|
65 | + { |
|
66 | + return $this->getApi()->request($this->getApi()->sprintf('/user/keys'), Request::METHOD_POST); |
|
67 | + } |
|
68 | 68 | |
69 | - /** |
|
70 | - * Delete a public key |
|
71 | - * |
|
72 | - * @link https://developer.github.com/v3/users/keys/#delete-a-public-key |
|
73 | - * |
|
74 | - * @param int $id |
|
75 | - * |
|
76 | - * @return array |
|
77 | - * @throws \Exception |
|
78 | - */ |
|
79 | - public function deletePublicKey(int $id): array |
|
80 | - { |
|
81 | - return $this->getApi()->request($this->getApi()->sprintf('/user/keys/:id', (string)$id), |
|
82 | - Request::METHOD_DELETE); |
|
83 | - } |
|
69 | + /** |
|
70 | + * Delete a public key |
|
71 | + * |
|
72 | + * @link https://developer.github.com/v3/users/keys/#delete-a-public-key |
|
73 | + * |
|
74 | + * @param int $id |
|
75 | + * |
|
76 | + * @return array |
|
77 | + * @throws \Exception |
|
78 | + */ |
|
79 | + public function deletePublicKey(int $id): array |
|
80 | + { |
|
81 | + return $this->getApi()->request($this->getApi()->sprintf('/user/keys/:id', (string)$id), |
|
82 | + Request::METHOD_DELETE); |
|
83 | + } |
|
84 | 84 | } |
85 | 85 | \ No newline at end of file |