| @@ -1,19 +1,19 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | - | |
| 4 | - | |
| 5 | -// 0 - none | |
| 3 | +// 0 - none. | |
| 6 | 4 | define( 'GEDEBUG_NONE', 0 ); |
| 7 | 5 | |
| 8 | -// 1 - call logging only | |
| 6 | +// 1 - call logging only. | |
| 9 | 7 | define( 'GEDEBUG_CALL', 1 ); |
| 10 | 8 | |
| 11 | -// 2 - calls, and responses | |
| 9 | +// 2 - calls, and responses. | |
| 12 | 10 | define( 'GEDEBUG_RESP', 2 ); |
| 13 | 11 | |
| 14 | -// Selected debug level | |
| 15 | -define( 'GITHUB_API_LEVEL', GEDEBUG_NONE ); | |
| 12 | +// Selected debug level. | |
| 13 | +if ( ! defined( 'GITHUB_API_LEVEL' ) ) { | |
| 14 | + define( 'GITHUB_API_LEVEL', GEDEBUG_NONE ); | |
| 15 | +} | |
| 16 | 16 | |
| 17 | 17 | |
| 18 | 18 | /** |
| 19 | 19 | * This class contains all the functions that actually retrieve information from the GitHub API |
| @@ -54,12 +54,10 @@ | ||
| 54 | 54 | * with GitHub(http://developer.github.com/v3/oauth/) use the filters here to |
| 55 | 55 | * provide the credentials. |
| 56 | 56 | */ |
| 57 | 57 | public function set_credentials() { |
| 58 | - | |
| 59 | 58 | $this->client_id = apply_filters( 'github-embed-client-id', $this->client_id ); |
| 60 | 59 | $this->client_secret = apply_filters( 'github-embed-client-secret', $this->client_secret ); |
| 61 | - | |
| 62 | 60 | } |
| 63 | 61 | |
| 64 | 62 | |
| 65 | 63 | |
| @@ -105,11 +103,8 @@ | ||
| 105 | 103 | public function get_repo( $owner, $repository ) { |
| 106 | 104 | |
| 107 | 105 | $this->log( "get_repo( $owner, $repository )", GEDEBUG_CALL ); |
| 108 | 106 | |
| 109 | - $owner = trim( $owner, '/' ); | |
| 110 | - $repository = trim( $repository, '/' ); | |
| 111 | - | |
| 112 | 107 | $results = $this->call_api( "https://api.github.com/repos/$owner/$repository" ); |
| 113 | 108 | |
| 114 | 109 | return json_decode( $results['body'] ); |
| 115 | 110 | |
| @@ -126,11 +121,8 @@ | ||
| 126 | 121 | public function get_repo_commits( $owner, $repository ) { |
| 127 | 122 | |
| 128 | 123 | $this->log( "get_repo_commits( $owner, $repository )", GEDEBUG_CALL ); |
| 129 | 124 | |
| 130 | - $owner = trim( $owner, '/' ); | |
| 131 | - $repository = trim( $repository, '/' ); | |
| 132 | - | |
| 133 | 125 | $results = $this->call_api( "https://api.github.com/repos/$owner/$repository/commits" ); |
| 134 | 126 | |
| 135 | 127 | return json_decode( $results['body'] ); |
| 136 | 128 | |
| @@ -148,11 +140,8 @@ | ||
| 148 | 140 | public function get_repo_milestone_summary( $owner, $repository, $milestone ) { |
| 149 | 141 | |
| 150 | 142 | $this->log( "get_repo_milestone_summary( $owner, $repository, $milestone )", GEDEBUG_CALL ); |
| 151 | 143 | |
| 152 | - $owner = trim( $owner, '/' ); | |
| 153 | - $repo = trim( $repository, '/' ); | |
| 154 | - | |
| 155 | 144 | $results = $this->call_api( "https://api.github.com/repos/$owner/$repository/milestones/$milestone" ); |
| 156 | 145 | |
| 157 | 146 | return json_decode( $results['body'] ); |
| 158 | 147 | |
| @@ -163,11 +152,8 @@ | ||
| 163 | 152 | public function get_repo_contributors( $owner, $repository ) { |
| 164 | 153 | |
| 165 | 154 | $this->log( "get_repo_contributors( $owner, $repository )", GEDEBUG_CALL ); |
| 166 | 155 | |
| 167 | - $owner = trim( $owner, '/' ); | |
| 168 | - $repo = trim( $repository, '/' ); | |
| 169 | - | |
| 170 | 156 | $results = $this->call_api( "https://api.github.com/repos/$owner/$repository/stats/contributors" ); |
| 171 | 157 | |
| 172 | 158 | return json_decode( $results['body'] ); |
| 173 | 159 | |
| @@ -182,10 +168,8 @@ | ||
| 182 | 168 | */ |
| 183 | 169 | public function get_user( $user ) { |
| 184 | 170 | |
| 185 | 171 | $this->log( "get_user( $user )", GEDEBUG_CALL ); |
| 186 | - | |
| 187 | - $user = trim( $user, '/' ); | |
| 188 | 172 | |
| 189 | 173 | $results = $this->call_api( "https://api.github.com/users/$user" ); |
| 190 | 174 | |
| 191 | 175 | return json_decode( $results['body'] ); |