-
Notifications
You must be signed in to change notification settings - Fork 0
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
3 changed files
with
268 additions
and
24 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
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,217 @@ | ||
<?php declare(strict_types=1); | ||
|
||
namespace Inhere\Kite\Common\GitLocal\GitLab; | ||
|
||
use Toolkit\Stdlib\Obj; | ||
|
||
/** | ||
* Class Project | ||
* | ||
* @package Inhere\Kite\Common\GitLocal\GitLab | ||
*/ | ||
class Project | ||
{ | ||
// '/' => '%2F' | ||
public const PID_SEP = '%2F'; | ||
|
||
/** | ||
* @var string | ||
*/ | ||
private $name; | ||
|
||
/** | ||
* The main group | ||
* | ||
* @var string | ||
*/ | ||
private $group; | ||
|
||
/** | ||
* The repository name | ||
* | ||
* @var string | ||
*/ | ||
private $repo; | ||
|
||
/** | ||
* Project Id for main group/repo | ||
* - int 123 | ||
* - string "group%2Frepo" | ||
* | ||
* @var string | ||
*/ | ||
private $mainPid; | ||
|
||
/** | ||
* @var string | ||
*/ | ||
private $forkGroup; | ||
|
||
/** | ||
* Project Id for forked-group/repo | ||
* - int 123 | ||
* - string "group%2Frepo" | ||
* | ||
* @var string | ||
*/ | ||
private $forkPid; | ||
|
||
/** | ||
* @param array $data | ||
* | ||
* @return static | ||
*/ | ||
public static function new(array $data): self | ||
{ | ||
return new self($data); | ||
} | ||
|
||
/** | ||
* @return array | ||
*/ | ||
public function toArray(): array | ||
{ | ||
return [ | ||
'name' => $this->name, | ||
'group' => $this->group, | ||
'repo' => $this->repo, | ||
'mainPid' => $this->mainPid, | ||
'forkGroup' => $this->forkGroup, | ||
'forkPid' => $this->forkPid, | ||
]; | ||
} | ||
|
||
/** | ||
* Class constructor. | ||
* | ||
* @param array $data | ||
*/ | ||
public function __construct(array $data = []) | ||
{ | ||
Obj::init($this, $data); | ||
} | ||
|
||
/** | ||
* @return string | ||
*/ | ||
public function getName(): string | ||
{ | ||
return $this->name; | ||
} | ||
|
||
/** | ||
* @param string $name | ||
* | ||
* @return Project | ||
*/ | ||
public function setName(string $name): Project | ||
{ | ||
$this->name = $name; | ||
return $this; | ||
} | ||
|
||
/** | ||
* @return string | ||
*/ | ||
public function getGroup(): string | ||
{ | ||
return $this->group; | ||
} | ||
|
||
/** | ||
* @param string $group | ||
* | ||
* @return Project | ||
*/ | ||
public function setGroup(string $group): Project | ||
{ | ||
$this->group = $group; | ||
return $this; | ||
} | ||
|
||
/** | ||
* @return string | ||
*/ | ||
public function getRepo(): string | ||
{ | ||
return $this->repo; | ||
} | ||
|
||
/** | ||
* @param string $repo | ||
* | ||
* @return Project | ||
*/ | ||
public function setRepo(string $repo): Project | ||
{ | ||
$this->repo = $repo; | ||
return $this; | ||
} | ||
|
||
/** | ||
* @param string|int $mainPid | ||
* | ||
* @return Project | ||
*/ | ||
public function setMainPid($mainPid): Project | ||
{ | ||
$this->mainPid = (string)$mainPid; | ||
return $this; | ||
} | ||
|
||
/** | ||
* @return string | ||
*/ | ||
public function getMainPid(): string | ||
{ | ||
if (!$this->mainPid) { | ||
// string pid: group + %2F + repo | ||
$this->mainPid = $this->group . self::PID_SEP . $this->repo; | ||
} | ||
|
||
return $this->mainPid; | ||
} | ||
|
||
/** | ||
* @return string | ||
*/ | ||
public function getForkGroup(): string | ||
{ | ||
return $this->forkGroup; | ||
} | ||
|
||
/** | ||
* @param string $forkGroup | ||
* | ||
* @return Project | ||
*/ | ||
public function setForkGroup(string $forkGroup): Project | ||
{ | ||
$this->forkGroup = $forkGroup; | ||
return $this; | ||
} | ||
|
||
/** | ||
* @return string | ||
*/ | ||
public function getForkPid(): string | ||
{ | ||
if (!$this->forkPid) { | ||
// string pid: group + %2F + repo | ||
$this->forkPid = $this->forkGroup . self::PID_SEP . $this->repo; | ||
} | ||
|
||
return $this->forkPid; | ||
} | ||
|
||
/** | ||
* @param string|int $forkPid | ||
* | ||
* @return Project | ||
*/ | ||
public function setForkPid($forkPid): Project | ||
{ | ||
$this->forkPid = (string)$forkPid; | ||
return $this; | ||
} | ||
} |
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