Skip to content

Commit

Permalink
[BC] Next big refactoring and clean up of internal API
Browse files Browse the repository at this point in the history
  • Loading branch information
stloyd committed Oct 1, 2012
1 parent 069c34e commit 9d2e680
Show file tree
Hide file tree
Showing 43 changed files with 991 additions and 1,020 deletions.
1 change: 1 addition & 0 deletions .gitignore
@@ -1,3 +1,4 @@
phpunit.xml
composer.lock
composer.phar
vendor/*
3 changes: 1 addition & 2 deletions .travis.yml
Expand Up @@ -5,8 +5,7 @@ php:
- 5.4

before_script:
- curl -s http://getcomposer.org/installer | php -- --quiet
- php composer.phar install --dev
- composer install --dev

script:
- phpunit --coverage-text
12 changes: 7 additions & 5 deletions composer.json
Expand Up @@ -3,7 +3,7 @@
"type": "library",
"description": "GitHub API v3 client",
"homepage": "https://github.com/KnpLabs/php-github-api",
"keywords": ["github", "api", "gist"],
"keywords": ["github", "gh", "api", "gist"],
"license": "MIT",
"authors": [
{
Expand All @@ -19,12 +19,14 @@
"require": {
"php": ">=5.3.2",
"ext-curl": "*",
"kriswallsmith/buzz": "0.7"
"kriswallsmith/buzz": ">=0.7"
},
"autoload": {
"psr-0": { "Github": "lib/" }
"psr-0": { "Github\\": "lib/" }
},
"config": {
"bin-dir": "bin/"
"extra": {
"branch-alias": {
"dev-master": "1.1.x-dev"
}
}
}
8 changes: 0 additions & 8 deletions doc/commits.md
Expand Up @@ -7,8 +7,6 @@ Wrap [GitHub Commit API](http://developer.github.com/v3/git/commits/).
### List commits in a branch

```php
<?php

$commits = $client->api('repo')->commits()->all('KnpLabs', 'php-github-api', array('sha' => 'master'));
```

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

```php
<?php

$commits = $client->api('repo')->commits()->all('KnpLabs', 'php-github-api', array('sha' => 'master', 'path' => 'README'));
```

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

```php
<?php

$commit = $client->api('repo')->commits()->show('KnpLabs', 'php-github-api', '839e5185da9434753db47959bee16642bb4f2ce4');
```

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

```php
<?php

$commit = $client->api('repo')->commits()->compare('KnpLabs', 'php-github-api', '839e5185da9434753db47959bee16642bb4f2ce4', 'b24a89060ca3f337c9b8c4fd2c929f60a5f2e33a');
```

Expand Down
19 changes: 3 additions & 16 deletions doc/customize.md
Expand Up @@ -6,8 +6,6 @@
Wanna change, let's say, the http client User Agent?

```php
<?php

$client->getHttpClient()->setOption('user_agent', 'My new User Agent');
```

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

```php
<?php

use Github\HttpClient\HttpClient;

// create a custom http client
class MyHttpClient extends HttpClient
{
public function doRequest($url, array $parameters = array(), $httpMethod = 'GET', array $options = array())
public function request($url, array $parameters = array(), $httpMethod = 'GET', array $headers = array())
{
// send the request and return the raw response
}
Expand All @@ -35,19 +31,10 @@ class MyHttpClient extends HttpClient

> Your http client implementation may not extend `Github\HttpClient\HttpClient`, but only implement `Github\HttpClient\HttpClientInterface`.
You can now inject your http client through `Github\Client` constructor:

```php
<?php

$client = new Github\Client(new MyHttpClient());
```

Or to an existing Github_Client instance:
You can now inject your http client through `Github\Client#setHttpClient()` method:

```php
<?php

$client = new Github\Client();
$client->setHttpClient(new MyHttpClient());
```

Expand Down
28 changes: 4 additions & 24 deletions doc/gists.md
Expand Up @@ -6,44 +6,36 @@ Creating, editing, deleting and listing gists. Wraps [GitHub Gists API](http://d
#### List all public gists.

```php
<?php

$gists = $github->api('gists')->all('public');
```

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

```php
<?php
> Requires [authentication](security.md).
$client->authenticate();
```php
$gists = $github->api('gists')->all('starred');
```

Requires authentication.

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

```php
<?php
> Requires [authentication](security.md) to list your gists.
// $client->authenticate();
```php
$gists = $github->api('gists')->all();
```

#### Get a single gist

```php
<?php

$gist = $github->api('gists')->show(1);
```

#### Create a gist

```php
<?php

$data = array(
'files' => array(
'filename.txt' => array(
Expand All @@ -64,8 +56,6 @@ Creates and returns a public gist.
You can update ``description``.

```php
<?php

$data = array(
'description' => 'This is new description'
);
Expand All @@ -76,8 +66,6 @@ $gist = $github->api('gists')->update($data);
You can update ``content`` of a previous file's version.

```php
<?php

$data = array(
'files' => array(
'filename.txt' => array(
Expand All @@ -91,8 +79,6 @@ $gist = $github->api('gists')->update(1234, $data);
You can update the ``filename`` of a previous file's version.

```php
<?php

$data = array(
'files' => array(
'filename.txt' => array(
Expand All @@ -106,8 +92,6 @@ $gist = $github->api('gists')->update(1234, $data);
You can add a new file to the gist.

```php
<?php

$data = array(
'files' => array(
'new-filename.php' => array(
Expand All @@ -121,8 +105,6 @@ $gist = $github->api('gists')->update(1234, $data);
You can remove a file from the gist.

```php
<?php

$data = array(
'files' => array(
'filename.txt' => null,
Expand All @@ -134,7 +116,5 @@ $gist = $github->api('gists')->update(1234, $data);
#### Delete a gist

```php
<?php

$gist = $github->api('gists')->remove(1234);
```
9 changes: 2 additions & 7 deletions doc/issue/comments.md
@@ -1,13 +1,11 @@
## Issues / Comments API
[Back to the "Issues API"](../issues.md) | [Back to the navigation](index.md)
[Back to the "Issues API"](../issues.md) | [Back to the navigation](../index.md)

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

### List an issue comments

```php
<?php

$comments = $client->api('issue')->comments()->all('KnpLabs', 'php-github-api', 4);
```

Expand All @@ -19,12 +17,9 @@ Returns an array of issues.
> **Note:**
> New comments are assigned to the authenticated user.
> Requires authentication.
> Requires [authentication](../security.md).
```php
<?php

$client->authenticate();
$client->api('issue')->comments()->create('KnpLabs', 'php-github-api', 4, array('body' => 'My new comment'));
```

Expand Down
24 changes: 5 additions & 19 deletions doc/issue/labels.md
@@ -1,13 +1,11 @@
## Issues / Labels API
[Back to the "Issues API"](../issues.md) | [Back to the navigation](index.md)
[Back to the "Issues API"](../issues.md) | [Back to the navigation](../index.md)

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

### List project labels

```php
<?php

$labels = $client->api('issue')->labels()->all('KnpLabs', 'php-github-api');
```

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

### Add a label on an issue

> Requires authentication.
> Requires [authentication](../security.md).
```php
<?php

$client->authenticate();
$labels = $client->api('issue')->labels()->add('KnpLabs', 'php-github-api', 4, 'label name');
```

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

### Replace all labels for an issue

> Requires authentication.
> Requires [authentication](../security.md).
```php
<?php

$client->authenticate();
$client->api('issue')->labels()->replace('KnpLabs', 'php-github-api', 4, array('new label name'));
```

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

### Remove all labels fom an issue

> Requires authentication.
> Requires [authentication](../security.md).
```php
<?php

$client->authenticate();
$client->api('issue')->labels()->replace('KnpLabs', 'php-github-api', 4);
```

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

### Remove a label from an issue

> Requires authentication.
> Requires [authentication](../security.md).
```php
<?php

$client->authenticate();
$client->api('issue')->labels()->remove('KnpLabs', 'php-github-api', 4, 'label name');
```

Expand Down

0 comments on commit 9d2e680

Please sign in to comment.