1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* Part of the Joomla Framework Github Package |
4
|
|
|
* |
5
|
|
|
* @copyright Copyright (C) 2005 - 2015 Open Source Matters, Inc. All rights reserved. |
6
|
|
|
* @license GNU General Public License version 2 or later; see LICENSE |
7
|
|
|
*/ |
8
|
|
|
|
9
|
|
|
namespace Joomla\Github\Package; |
10
|
|
|
|
11
|
|
|
use Joomla\Github\AbstractPackage; |
12
|
|
|
|
13
|
|
|
/** |
14
|
|
|
* GitHub API Activity class for the Joomla Framework. |
15
|
|
|
* |
16
|
|
|
* @since 1.0 |
17
|
|
|
* |
18
|
|
|
* @documentation http://developer.github.com/v3/orgs/ |
19
|
|
|
* |
20
|
|
|
* @property-read Orgs\Hooks $hooks GitHub API object for hooks. |
21
|
|
|
* @property-read Orgs\Members $members GitHub API object for members. |
22
|
|
|
* @property-read Orgs\Teams $teams GitHub API object for teams. |
23
|
|
|
*/ |
24
|
|
|
class Orgs extends AbstractPackage |
25
|
|
|
{ |
26
|
|
|
/** |
27
|
|
|
* List user organizations. |
28
|
|
|
* |
29
|
|
|
* If a user name is given, public and private organizations for the authenticated user will be listed. |
30
|
|
|
* |
31
|
|
|
* @param string $user The user name. |
32
|
|
|
* |
33
|
|
|
* @return object |
34
|
|
|
* |
35
|
|
|
* @since 1.0 |
36
|
|
|
*/ |
37
|
|
View Code Duplication |
public function getList($user = '') |
|
|
|
|
38
|
|
|
{ |
39
|
|
|
// Build the request path. |
40
|
|
|
$path = ($user) |
41
|
|
|
? '/users/' . $user . '/orgs' |
42
|
|
|
: '/user/orgs'; |
43
|
|
|
|
44
|
|
|
// Send the request. |
45
|
|
|
return $this->processResponse( |
46
|
|
|
$this->client->get($this->fetchUrl($path)) |
47
|
|
|
); |
48
|
|
|
} |
49
|
|
|
|
50
|
|
|
/** |
51
|
|
|
* Get an organization. |
52
|
|
|
* |
53
|
|
|
* @param string $org The organization name. |
54
|
|
|
* |
55
|
|
|
* @return object |
56
|
|
|
* |
57
|
|
|
* @since 1.0 |
58
|
|
|
*/ |
59
|
|
|
public function get($org) |
60
|
|
|
{ |
61
|
|
|
// Build the request path. |
62
|
|
|
$path = '/orgs/' . $org; |
63
|
|
|
|
64
|
|
|
// Send the request. |
65
|
|
|
return $this->processResponse( |
66
|
|
|
$this->client->get($this->fetchUrl($path)) |
67
|
|
|
); |
68
|
|
|
} |
69
|
|
|
|
70
|
|
|
/** |
71
|
|
|
* Edit an organization. |
72
|
|
|
* |
73
|
|
|
* @param string $org The organization name. |
74
|
|
|
* @param string $billingEmail Billing email address. This address is not publicized. |
75
|
|
|
* @param string $company The company name. |
76
|
|
|
* @param string $email The email address. |
77
|
|
|
* @param string $location The location name. |
78
|
|
|
* @param string $name The name. |
79
|
|
|
* |
80
|
|
|
* @return object |
81
|
|
|
* |
82
|
|
|
* @since 1.0 |
83
|
|
|
*/ |
84
|
|
|
public function edit($org, $billingEmail = '', $company = '', $email = '', $location = '', $name = '') |
|
|
|
|
85
|
|
|
{ |
86
|
|
|
// Build the request path. |
87
|
|
|
$path = '/orgs/' . $org; |
88
|
|
|
|
89
|
|
|
$args = array('billing_email', 'company', 'email', 'location', 'name'); |
90
|
|
|
|
91
|
|
|
$data = array(); |
92
|
|
|
|
93
|
|
|
$fArgs = func_get_args(); |
94
|
|
|
|
95
|
|
|
foreach ($args as $i => $arg) |
96
|
|
|
{ |
97
|
|
|
if (array_key_exists($i + 1, $fArgs) && $fArgs[$i + 1]) |
98
|
|
|
{ |
99
|
|
|
$data[$arg] = $fArgs[$i + 1]; |
100
|
|
|
} |
101
|
|
|
} |
102
|
|
|
|
103
|
|
|
// Send the request. |
104
|
|
|
return $this->processResponse( |
105
|
|
|
$this->client->patch($this->fetchUrl($path), $data) |
106
|
|
|
); |
107
|
|
|
} |
108
|
|
|
} |
109
|
|
|
|
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.