-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
70 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,8 @@ | |
|
||
namespace Jmleroux\CircleCi\Model; | ||
|
||
use Jmleroux\CircleCi\Model\Project\VcsInfo; | ||
|
||
/** | ||
* @author jmleroux <[email protected]> | ||
* @link https://circleci.com/docs/api/#get-all-followed-projects | ||
|
@@ -12,10 +14,8 @@ class Project implements ApiResultInterface | |
{ | ||
/** | ||
* Raw object from Circle CI API | ||
* | ||
* @var \stdClass | ||
*/ | ||
private $rawObject; | ||
private \stdClass $rawObject; | ||
|
||
private function __construct(\stdClass $rawObject) | ||
{ | ||
|
@@ -32,28 +32,38 @@ public function rawValues(): \stdClass | |
return $this->rawObject; | ||
} | ||
|
||
public function vcsUrl(): string | ||
public function slug(): string | ||
{ | ||
return $this->rawObject->slug; | ||
} | ||
|
||
public function name(): string | ||
{ | ||
return $this->rawObject->slug; | ||
} | ||
|
||
public function id(): string | ||
{ | ||
return $this->rawObject->vcs_url; | ||
return $this->rawObject->slug; | ||
} | ||
|
||
public function followed(): bool | ||
public function organizationName(): string | ||
{ | ||
return $this->rawObject->followed ?? false; | ||
return $this->rawObject->organization_name; | ||
} | ||
|
||
public function username(): string | ||
public function organizationSlug(): string | ||
{ | ||
return $this->rawObject->username; | ||
return $this->rawObject->organization_slug; | ||
} | ||
|
||
public function reponame(): string | ||
public function organizationId(): string | ||
{ | ||
return $this->rawObject->reponame; | ||
return $this->rawObject->organization_id; | ||
} | ||
|
||
public function branches(): \stdClass | ||
public function vcsInfo(): VcsInfo | ||
{ | ||
return $this->rawObject->branches; | ||
return VcsInfo::createFromApi($this->rawObject->vcs_info); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Jmleroux\CircleCi\Model\Project; | ||
|
||
use Jmleroux\CircleCi\Model\ApiResultInterface; | ||
use Jmleroux\CircleCi\Model\Pipeline\Vcs\Commit; | ||
|
||
/** | ||
* @author Brice Le Boulch <[email protected]> | ||
* @link https://circleci.com/docs/api/v2/index.html#operation/getPipelineById | ||
*/ | ||
final class VcsInfo implements ApiResultInterface | ||
{ | ||
private \stdClass $rawObject; | ||
|
||
private function __construct(\stdClass $rawObject) | ||
{ | ||
$this->rawObject = $rawObject; | ||
} | ||
|
||
public static function createFromApi(\stdClass $rawObject): self | ||
{ | ||
return new self($rawObject); | ||
} | ||
|
||
public function rawValues(): \stdClass | ||
{ | ||
return $this->rawObject; | ||
} | ||
|
||
public function vcsUrl(): string | ||
{ | ||
return $this->rawObject->vcs_url; | ||
} | ||
|
||
public function provider(): string | ||
{ | ||
return $this->rawObject->provider; | ||
} | ||
|
||
public function defaultBranch(): string | ||
{ | ||
return $this->rawObject->default_branch; | ||
} | ||
} |