Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,17 @@ sudo: false
php:
- 5.6
- 7.0
- 7.1

matrix:
include:
- php: 7.1
env: STATIC_ANALYSIS=yes

before_script:
- travis_retry composer self-update
- travis_retry composer install --no-interaction --prefer-source
- if [ "$STATIC_ANALYSIS" != "" ]; then curl -L https://github.com/phpstan/phpstan/releases/download/0.8/phpstan.phar -o phpstan.phar; fi;

script:
- vendor/bin/phpunit --verbose --coverage-text
- if [ "$STATIC_ANALYSIS" != "" ]; then php phpstan.phar analyse --level=4 lib; fi;
10 changes: 5 additions & 5 deletions lib/Gitlab/Api/IssueBoards.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,16 +63,16 @@ public function createList($project_id, $board_id, $label_id)
/**
* @param int $project_id
* @param int $board_id
* @param int $label_id
* @param int $list_id
* @param int $position
* @return mixed
*/
public function updateList($project_id, $board_id, $label_id, $position)
public function updateList($project_id, $board_id, $list_id, $position)
{
$params = array(
'id' => $project_id,
'board_id' => $board_id,
'label_id' => $label_id,
'list_id' => $list_id,
'position' => $position
);

Expand All @@ -82,10 +82,10 @@ public function updateList($project_id, $board_id, $label_id, $position)
/**
* @param int $project_id
* @param int $board_id
* @param int $label_id
* @param int $list_id
* @return mixed
*/
public function deleteList($project_id, $board_id, $label_id)
public function deleteList($project_id, $board_id, $list_id)
{
return $this->delete($this->getProjectPath($project_id, 'boards/'.$this->encodePath($board_id).'/lists/'.$this->encodePath($list_id)));
}
Expand Down
8 changes: 8 additions & 0 deletions lib/Gitlab/Api/Users.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,14 @@ public function show($id)
return $this->get('users/'.$this->encodePath($id));
}

/**
* @return mixed
*/
public function user()
{
return $this->get('user');
}

/**
* @param string $email
* @param string $password
Expand Down
167 changes: 135 additions & 32 deletions lib/Gitlab/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,126 @@ public static function createWithHttpClient(HttpClient $httpClient)
return new self($builder);
}

/**
* @return Api\DeployKeys
*/
public function deployKeys()
{
return new Api\DeployKeys($this);
}

/**
* @return Api\Groups
*/
public function groups()
{
return new Api\Groups($this);
}

/**
* @return Api\Issues
*/
public function issues()
{
return new Api\Issues($this);
}

/**
* @return Api\IssueBoards
*/
public function issueBoards()
{
return new Api\IssueBoards($this);
}

/**
* @return Api\Jobs
*/
public function jobs()
{
return new Api\Jobs($this);
}

/**
* @return Api\MergeRequests
*/
public function mergeRequests()
{
return new Api\MergeRequests($this);
}

/**
* @return Api\Milestones
*/
public function milestones()
{
return new Api\Milestones($this);
}

/**
* @return Api\ProjectNamespaces
*/
public function namespaces()
{
return new Api\ProjectNamespaces($this);
}

/**
* @return Api\Projects
*/
public function projects()
{
return new Api\Projects($this);
}

/**
* @return Api\Repositories
*/
public function repositories()
{
return new Api\Repositories($this);
}

/**
* @return Api\Snippets
*/
public function snippets()
{
return new Api\Snippets($this);
}

/**
* @return Api\SystemHooks
*/
public function systemHooks()
{
return new Api\SystemHooks($this);
}

/**
* @return Api\Users
*/
public function users()
{
return new Api\Users($this);
}

/**
* @return Api\Keys
*/
public function keys()
{
return new Api\Keys($this);
}

/**
* @return Api\Tags
*/
public function tags()
{
return new Api\Tags($this);
}

/**
* @param string $name
*
Expand All @@ -128,75 +248,58 @@ public function api($name)
switch ($name) {

case 'deploy_keys':
$api = new Api\DeployKeys($this);
break;
return $this->deployKeys();

case 'groups':
$api = new Api\Groups($this);
break;
return $this->groups();

case 'issues':
$api = new Api\Issues($this);
break;
return $this->issues();

case 'board':
case 'issue_boards':
$api = new Api\IssueBoards($this);
return $this->issueBoards();
case 'jobs':
$api = new Api\Jobs($this);
break;
return $this->jobs();

case 'mr':
case 'merge_requests':
$api = new Api\MergeRequests($this);
break;
return $this->mergeRequests();

case 'milestones':
case 'ms':
$api = new Api\Milestones($this);
break;
return $this->milestones();

case 'namespaces':
case 'ns':
$api = new Api\ProjectNamespaces($this);
break;
return $this->namespaces();

case 'projects':
$api = new Api\Projects($this);
break;
return $this->projects();

case 'repo':
case 'repositories':
$api = new Api\Repositories($this);
break;
return $this->repositories();

case 'snippets':
$api = new Api\Snippets($this);
break;
return $this->snippets();

case 'hooks':
case 'system_hooks':
$api = new Api\SystemHooks($this);
break;
return $this->systemHooks();

case 'users':
$api = new Api\Users($this);
break;
return $this->users();

case 'keys':
$api = new Api\Keys($this);
break;
return $this->keys();

case 'tags':
$api = new Api\Tags($this);
break;
return $this->tags();

default:
throw new InvalidArgumentException('Invalid endpoint: "'.$name.'"');

}

return $api;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion lib/Gitlab/HttpClient/Builder.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class Builder
/**
* A HTTP client with all our plugins.
*
* @var PluginClient
* @var HttpMethodsClient
*/
private $pluginClient;

Expand Down
14 changes: 7 additions & 7 deletions lib/Gitlab/Model/Branch.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public function __construct(Project $project, $name = null, Client $client = nul
*/
public function show()
{
$data = $this->api('repositories')->branch($this->project->id, $this->name);
$data = $this->client->repositories()->branch($this->project->id, $this->name);

return static::fromArray($this->getClient(), $this->project, $data);
}
Expand All @@ -69,7 +69,7 @@ public function show()
*/
public function protect($devPush = false, $devMerge = false)
{
$data = $this->api('repositories')->protectBranch($this->project->id, $this->name, $devPush, $devMerge);
$data = $this->client->repositories()->protectBranch($this->project->id, $this->name, $devPush, $devMerge);

return static::fromArray($this->getClient(), $this->project, $data);
}
Expand All @@ -79,7 +79,7 @@ public function protect($devPush = false, $devMerge = false)
*/
public function unprotect()
{
$data = $this->api('repositories')->unprotectBranch($this->project->id, $this->name);
$data = $this->client->repositories()->unprotectBranch($this->project->id, $this->name);

return static::fromArray($this->getClient(), $this->project, $data);
}
Expand All @@ -89,7 +89,7 @@ public function unprotect()
*/
public function delete()
{
$this->api('repositories')->deleteBranch($this->project->id, $this->name);
$this->client->repositories()->deleteBranch($this->project->id, $this->name);

return true;
}
Expand All @@ -112,7 +112,7 @@ public function commits($page = 1, $per_page = Api::PER_PAGE)
*/
public function createFile($file_path, $content, $commit_message)
{
$data = $this->api('repositories')->createFile($this->project->id, $file_path, $content, $this->name, $commit_message);
$data = $this->client->repositories()->createFile($this->project->id, $file_path, $content, $this->name, $commit_message);

return File::fromArray($this->getClient(), $this->project, $data);
}
Expand All @@ -125,7 +125,7 @@ public function createFile($file_path, $content, $commit_message)
*/
public function updateFile($file_path, $content, $commit_message)
{
$data = $this->api('repositories')->updateFile($this->project->id, $file_path, $content, $this->name, $commit_message);
$data = $this->client->repositories()->updateFile($this->project->id, $file_path, $content, $this->name, $commit_message);

return File::fromArray($this->getClient(), $this->project, $data);
}
Expand All @@ -137,7 +137,7 @@ public function updateFile($file_path, $content, $commit_message)
*/
public function deleteFile($file_path, $commit_message)
{
$this->api('repositories')->deleteFile($this->project->id, $file_path, $this->name, $commit_message);
$this->client->repositories()->deleteFile($this->project->id, $file_path, $this->name, $commit_message);

return true;
}
Expand Down
Loading