-
-
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
91 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,26 @@ public function getVendor(): string | |
return $this->vendor; | ||
} | ||
|
||
public function isGitHub(): array|bool | ||
{ | ||
if (Preg::isMatchStrictGroups('{^(?:git://|git@|https?://)github.com[:/]([^/]+)/(.+?)(?:\.git|/)?$}i', $this->getRepository(), $match)) { | ||
return $match; | ||
} | ||
else { | ||
return false; | ||
} | ||
} | ||
|
||
public function isGitLab(): array|bool | ||
{ | ||
if (Preg::isMatchStrictGroups('{^(?:git://|git@|https?://)gitlab.com[:/]([^/]+)/(.+?)(?:\.git|/)?$}i', $this->getRepository(), $match)) { | ||
return $match; | ||
} | ||
else { | ||
return false; | ||
} | ||
} | ||
|
||
/** | ||
* Get package name without vendor | ||
*/ | ||
|
@@ -334,6 +354,19 @@ public function getGitHubStars(): int|null | |
return $this->gitHubStars; | ||
} | ||
|
||
public function getGitHubStarsUrl(): string|null | ||
{ | ||
if ($this->isGitHub()) { | ||
return $this->getBrowsableRepository() . '/stargazers'; | ||
} | ||
else if ($this->isGitLab()) { | ||
return $this->getBrowsableRepository() . '/-/starrers'; | ||
} | ||
else { | ||
return null; | ||
} | ||
} | ||
|
||
public function setGitHubWatches(int|null $val): void | ||
{ | ||
$this->gitHubWatches = $val; | ||
|
@@ -354,6 +387,19 @@ public function getGitHubForks(): int|null | |
return $this->gitHubForks; | ||
} | ||
|
||
public function getGitHubForksUrl(): string|null | ||
{ | ||
if ($this->isGitHub()) { | ||
return $this->getBrowsableRepository() . '/forks'; | ||
} | ||
else if ($this->isGitLab()) { | ||
return $this->getBrowsableRepository() . '/-/forks'; | ||
} | ||
else { | ||
return null; | ||
} | ||
} | ||
|
||
public function setGitHubOpenIssues(int|null $val): void | ||
{ | ||
$this->gitHubOpenIssues = $val; | ||
|
@@ -467,7 +513,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