-
-
Notifications
You must be signed in to change notification settings - Fork 475
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
93 additions
and
6 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 |
---|---|---|
|
@@ -274,6 +274,30 @@ public function getVendor(): string | |
return $this->vendor; | ||
} | ||
|
||
/** | ||
* @return array<string> Vendor and package name | ||
*/ | ||
public function isGitHub(): array|false | ||
{ | ||
if (Preg::isMatchStrictGroups('{^(?:git://|git@|https?://)github.com[:/]([^/]+)/(.+?)(?:\.git|/)?$}i', $this->getRepository(), $match)) { | ||
return $match; | ||
} | ||
|
||
return false; | ||
} | ||
|
||
/** | ||
* @return array<string> Vendor and package name | ||
*/ | ||
public function isGitLab(): array|false | ||
{ | ||
if (Preg::isMatchStrictGroups('{^(?:git://|git@|https?://)gitlab.com[:/]([^/]+)/(.+?)(?:\.git|/)?$}i', $this->getRepository(), $match)) { | ||
return $match; | ||
} | ||
|
||
return false; | ||
} | ||
|
||
/** | ||
* Get package name without vendor | ||
*/ | ||
|
@@ -334,6 +358,18 @@ public function getGitHubStars(): int|null | |
return $this->gitHubStars; | ||
} | ||
|
||
public function getGitHubStarsUrl(): string|null | ||
{ | ||
if ($this->isGitHub()) { | ||
return $this->getBrowsableRepository() . '/stargazers'; | ||
} | ||
if ($this->isGitLab()) { | ||
return $this->getBrowsableRepository() . '/-/starrers'; | ||
} | ||
|
||
return null; | ||
} | ||
|
||
public function setGitHubWatches(int|null $val): void | ||
{ | ||
$this->gitHubWatches = $val; | ||
|
@@ -354,6 +390,18 @@ public function getGitHubForks(): int|null | |
return $this->gitHubForks; | ||
} | ||
|
||
public function getGitHubForksUrl(): string|null | ||
{ | ||
if ($this->isGitHub()) { | ||
return $this->getBrowsableRepository() . '/forks'; | ||
} | ||
if ($this->isGitLab()) { | ||
return $this->getBrowsableRepository() . '/-/forks'; | ||
} | ||
|
||
return null; | ||
} | ||
|
||
public function setGitHubOpenIssues(int|null $val): void | ||
{ | ||
$this->gitHubOpenIssues = $val; | ||
|
@@ -467,7 +515,15 @@ public function getBrowsableRepository(): string | |
return Preg::replace('{^(?:git@|https://|git://)bitbucket.org[:/](.+?)(?:\.git)?$}i', 'https://bitbucket.org/$1', $this->repository); | ||
} | ||
|
||
return Preg::replace('{^(git://github.com/|[email protected]:)}', 'https://github.com/', $this->repository); | ||
if (Preg::isMatch('{(://|@)github.com[:/]}i', $this->repository)) { | ||
return Preg::replace('{^(git://github.com/|[email protected]:)}', 'https://github.com/', $this->repository); | ||
} | ||
|
||
if (Preg::isMatch('{(://|@)gitlab.com[:/]}i', $this->repository)) { | ||
return Preg::replace('{^(git://gitlab.com/|[email protected]:)}', 'https://gitlab.com/', $this->repository); | ||
} | ||
|
||
return $this->repository; | ||
} | ||
|
||
public function addVersion(Version $version): void | ||
|
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