Skip to content

Commit 9d2e680

Browse files
committed
[BC] Next big refactoring and clean up of internal API
1 parent 069c34e commit 9d2e680

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+991
-1020
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
phpunit.xml
12
composer.lock
23
composer.phar
34
vendor/*

.travis.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@ php:
55
- 5.4
66

77
before_script:
8-
- curl -s http://getcomposer.org/installer | php -- --quiet
9-
- php composer.phar install --dev
8+
- composer install --dev
109

1110
script:
1211
- phpunit --coverage-text

composer.json

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"type": "library",
44
"description": "GitHub API v3 client",
55
"homepage": "https://github.com/KnpLabs/php-github-api",
6-
"keywords": ["github", "api", "gist"],
6+
"keywords": ["github", "gh", "api", "gist"],
77
"license": "MIT",
88
"authors": [
99
{
@@ -19,12 +19,14 @@
1919
"require": {
2020
"php": ">=5.3.2",
2121
"ext-curl": "*",
22-
"kriswallsmith/buzz": "0.7"
22+
"kriswallsmith/buzz": ">=0.7"
2323
},
2424
"autoload": {
25-
"psr-0": { "Github": "lib/" }
25+
"psr-0": { "Github\\": "lib/" }
2626
},
27-
"config": {
28-
"bin-dir": "bin/"
27+
"extra": {
28+
"branch-alias": {
29+
"dev-master": "1.1.x-dev"
30+
}
2931
}
3032
}

doc/commits.md

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@ Wrap [GitHub Commit API](http://developer.github.com/v3/git/commits/).
77
### List commits in a branch
88

99
```php
10-
<?php
11-
1210
$commits = $client->api('repo')->commits()->all('KnpLabs', 'php-github-api', array('sha' => 'master'));
1311
```
1412

@@ -17,8 +15,6 @@ Returns an array of commits.
1715
### List commits for a file
1816

1917
```php
20-
<?php
21-
2218
$commits = $client->api('repo')->commits()->all('KnpLabs', 'php-github-api', array('sha' => 'master', 'path' => 'README'));
2319
```
2420

@@ -27,8 +23,6 @@ Returns an array of commits.
2723
### Get a single commit
2824

2925
```php
30-
<?php
31-
3226
$commit = $client->api('repo')->commits()->show('KnpLabs', 'php-github-api', '839e5185da9434753db47959bee16642bb4f2ce4');
3327
```
3428

@@ -37,8 +31,6 @@ Returns a single commit.
3731
### Compare commits
3832

3933
```php
40-
<?php
41-
4234
$commit = $client->api('repo')->commits()->compare('KnpLabs', 'php-github-api', '839e5185da9434753db47959bee16642bb4f2ce4', 'b24a89060ca3f337c9b8c4fd2c929f60a5f2e33a');
4335
```
4436

doc/customize.md

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@
66
Wanna change, let's say, the http client User Agent?
77

88
```php
9-
<?php
10-
119
$client->getHttpClient()->setOption('user_agent', 'My new User Agent');
1210
```
1311

@@ -19,14 +17,12 @@ See all available options in `Github/HttpClient/HttpClient.php`
1917
If you want to use your own http client implementation, inject it to the `Github\Client` instance:
2018

2119
```php
22-
<?php
23-
2420
use Github\HttpClient\HttpClient;
2521

2622
// create a custom http client
2723
class MyHttpClient extends HttpClient
2824
{
29-
public function doRequest($url, array $parameters = array(), $httpMethod = 'GET', array $options = array())
25+
public function request($url, array $parameters = array(), $httpMethod = 'GET', array $headers = array())
3026
{
3127
// send the request and return the raw response
3228
}
@@ -35,19 +31,10 @@ class MyHttpClient extends HttpClient
3531

3632
> Your http client implementation may not extend `Github\HttpClient\HttpClient`, but only implement `Github\HttpClient\HttpClientInterface`.
3733
38-
You can now inject your http client through `Github\Client` constructor:
39-
40-
```php
41-
<?php
42-
43-
$client = new Github\Client(new MyHttpClient());
44-
```
45-
46-
Or to an existing Github_Client instance:
34+
You can now inject your http client through `Github\Client#setHttpClient()` method:
4735

4836
```php
49-
<?php
50-
37+
$client = new Github\Client();
5138
$client->setHttpClient(new MyHttpClient());
5239
```
5340

doc/gists.md

Lines changed: 4 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -6,44 +6,36 @@ Creating, editing, deleting and listing gists. Wraps [GitHub Gists API](http://d
66
#### List all public gists.
77

88
```php
9-
<?php
10-
119
$gists = $github->api('gists')->all('public');
1210
```
1311

1412
#### List the authenticated user’s starred gists.
1513

16-
```php
17-
<?php
14+
> Requires [authentication](security.md).
1815
19-
$client->authenticate();
16+
```php
2017
$gists = $github->api('gists')->all('starred');
2118
```
2219

2320
Requires authentication.
2421

2522
#### List the authenticated user’s gists or if called anonymously, this will return all public gists.
2623

27-
```php
28-
<?php
24+
> Requires [authentication](security.md) to list your gists.
2925
30-
// $client->authenticate();
26+
```php
3127
$gists = $github->api('gists')->all();
3228
```
3329

3430
#### Get a single gist
3531

3632
```php
37-
<?php
38-
3933
$gist = $github->api('gists')->show(1);
4034
```
4135

4236
#### Create a gist
4337

4438
```php
45-
<?php
46-
4739
$data = array(
4840
'files' => array(
4941
'filename.txt' => array(
@@ -64,8 +56,6 @@ Creates and returns a public gist.
6456
You can update ``description``.
6557

6658
```php
67-
<?php
68-
6959
$data = array(
7060
'description' => 'This is new description'
7161
);
@@ -76,8 +66,6 @@ $gist = $github->api('gists')->update($data);
7666
You can update ``content`` of a previous file's version.
7767

7868
```php
79-
<?php
80-
8169
$data = array(
8270
'files' => array(
8371
'filename.txt' => array(
@@ -91,8 +79,6 @@ $gist = $github->api('gists')->update(1234, $data);
9179
You can update the ``filename`` of a previous file's version.
9280

9381
```php
94-
<?php
95-
9682
$data = array(
9783
'files' => array(
9884
'filename.txt' => array(
@@ -106,8 +92,6 @@ $gist = $github->api('gists')->update(1234, $data);
10692
You can add a new file to the gist.
10793

10894
```php
109-
<?php
110-
11195
$data = array(
11296
'files' => array(
11397
'new-filename.php' => array(
@@ -121,8 +105,6 @@ $gist = $github->api('gists')->update(1234, $data);
121105
You can remove a file from the gist.
122106

123107
```php
124-
<?php
125-
126108
$data = array(
127109
'files' => array(
128110
'filename.txt' => null,
@@ -134,7 +116,5 @@ $gist = $github->api('gists')->update(1234, $data);
134116
#### Delete a gist
135117

136118
```php
137-
<?php
138-
139119
$gist = $github->api('gists')->remove(1234);
140120
```

doc/issue/comments.md

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
11
## Issues / Comments API
2-
[Back to the "Issues API"](../issues.md) | [Back to the navigation](index.md)
2+
[Back to the "Issues API"](../issues.md) | [Back to the navigation](../index.md)
33

44
Wraps [GitHub Issue Comments API](http://developer.github.com/v3/issues/comments/).
55

66
### List an issue comments
77

88
```php
9-
<?php
10-
119
$comments = $client->api('issue')->comments()->all('KnpLabs', 'php-github-api', 4);
1210
```
1311

@@ -19,12 +17,9 @@ Returns an array of issues.
1917
> **Note:**
2018
> New comments are assigned to the authenticated user.
2119
22-
> Requires authentication.
20+
> Requires [authentication](../security.md).
2321
2422
```php
25-
<?php
26-
27-
$client->authenticate();
2823
$client->api('issue')->comments()->create('KnpLabs', 'php-github-api', 4, array('body' => 'My new comment'));
2924
```
3025

doc/issue/labels.md

Lines changed: 5 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
11
## Issues / Labels API
2-
[Back to the "Issues API"](../issues.md) | [Back to the navigation](index.md)
2+
[Back to the "Issues API"](../issues.md) | [Back to the navigation](../index.md)
33

44
Wraps [GitHub Issue Labels API](http://developer.github.com/v3/issues/labels/).
55

66
### List project labels
77

88
```php
9-
<?php
10-
119
$labels = $client->api('issue')->labels()->all('KnpLabs', 'php-github-api');
1210
```
1311

@@ -16,12 +14,9 @@ Returns an array of project labels.
1614

1715
### Add a label on an issue
1816

19-
> Requires authentication.
17+
> Requires [authentication](../security.md).
2018
2119
```php
22-
<?php
23-
24-
$client->authenticate();
2520
$labels = $client->api('issue')->labels()->add('KnpLabs', 'php-github-api', 4, 'label name');
2621
```
2722

@@ -31,38 +26,29 @@ Returns an array of the issue labels.
3126

3227
### Replace all labels for an issue
3328

34-
> Requires authentication.
29+
> Requires [authentication](../security.md).
3530
3631
```php
37-
<?php
38-
39-
$client->authenticate();
4032
$client->api('issue')->labels()->replace('KnpLabs', 'php-github-api', 4, array('new label name'));
4133
```
4234

4335
Replace a label for an issue: by username, repo, issue number and array of labels.
4436

4537
### Remove all labels fom an issue
4638

47-
> Requires authentication.
39+
> Requires [authentication](../security.md).
4840
4941
```php
50-
<?php
51-
52-
$client->authenticate();
5342
$client->api('issue')->labels()->replace('KnpLabs', 'php-github-api', 4);
5443
```
5544

5645
Removal of all labels for the issue by username, repo, issue number.
5746

5847
### Remove a label from an issue
5948

60-
> Requires authentication.
49+
> Requires [authentication](../security.md).
6150
6251
```php
63-
<?php
64-
65-
$client->authenticate();
6652
$client->api('issue')->labels()->remove('KnpLabs', 'php-github-api', 4, 'label name');
6753
```
6854

0 commit comments

Comments
 (0)