From 5a648b9f422182e73023f25341987e20550ab6f6 Mon Sep 17 00:00:00 2001 From: Robbie Averill Date: Wed, 6 Dec 2023 23:48:19 -0800 Subject: [PATCH] Add new properties to Package, Version, and Maintainer New support added for properties: Package: getGithubWatchers(), getGithubOpenIssues(), getLanguage() Version: getSupport(), getTargetDir(), getDefaultBranch() Maintainer: getAvatarUrl() --- .../Api/Result/Package/MaintainerSpec.php | 5 ++++ .../Api/Result/Package/VersionSpec.php | 24 +++++++++++++++++++ spec/Packagist/Api/Result/PackageSpec.php | 18 ++++++++++++++ src/Packagist/Api/Result/Package.php | 21 ++++++++++++++++ .../Api/Result/Package/Maintainer.php | 7 ++++++ src/Packagist/Api/Result/Package/Version.php | 21 ++++++++++++++++ 6 files changed, 96 insertions(+) diff --git a/spec/Packagist/Api/Result/Package/MaintainerSpec.php b/spec/Packagist/Api/Result/Package/MaintainerSpec.php index aff5c25..fca4a87 100644 --- a/spec/Packagist/Api/Result/Package/MaintainerSpec.php +++ b/spec/Packagist/Api/Result/Package/MaintainerSpec.php @@ -15,6 +15,7 @@ public function let() 'name' => 'Saša Stamenković', 'email' => 'umpirsky@gmail.com', 'homepage' => 'umpirsky.com', + 'avatar_url' => 'https://www.gravatar.com/avatar/example', ]); } @@ -38,4 +39,8 @@ public function it_gets_homepage() $this->getHomepage()->shouldReturn('umpirsky.com'); } + public function it_gets_avatar_url() + { + $this->getAvatarUrl()->shouldReturn('https://www.gravatar.com/avatar/example'); + } } diff --git a/spec/Packagist/Api/Result/Package/VersionSpec.php b/spec/Packagist/Api/Result/Package/VersionSpec.php index cdfc04d..f7f346f 100644 --- a/spec/Packagist/Api/Result/Package/VersionSpec.php +++ b/spec/Packagist/Api/Result/Package/VersionSpec.php @@ -34,6 +34,12 @@ public function let(Author $author, Source $source, Dist $dist) 'require-dev' => ['phpspec/phpspec2' => 'dev-develop'], 'suggest' => ['illuminate/events' => 'Required to use the observers with Eloquent (5.1.*).'], 'bin' => ['bin/sylius'], + 'support' => [ + 'issues' => 'https://github.com/Sylius/Sylius/issues', + 'source' => 'https://github.com/Sylius/Sylius/tree/v0.1.0', + ], + 'target_dir' => '', + 'default_branch' => false, ]); } @@ -173,4 +179,22 @@ public function it_gets_replacement_package_returning_null() $this->getReplacementPackage()->shouldReturn(null); } + + public function it_gets_support() + { + $this->getSupport()->shouldReturn([ + 'issues' => 'https://github.com/Sylius/Sylius/issues', + 'source' => 'https://github.com/Sylius/Sylius/tree/v0.1.0', + ]); + } + + public function it_gets_target_dir() + { + $this->getTargetDir()->shouldReturn(''); + } + + public function it_gets_default_branch() + { + $this->getDefaultBranch()->shouldReturn(false); + } } diff --git a/spec/Packagist/Api/Result/PackageSpec.php b/spec/Packagist/Api/Result/PackageSpec.php index 089b09f..5e26c4d 100644 --- a/spec/Packagist/Api/Result/PackageSpec.php +++ b/spec/Packagist/Api/Result/PackageSpec.php @@ -29,8 +29,11 @@ public function let(Maintainer $maintainer, Version $version, Downloads $downloa 'dependents' => 42, 'github_stars' => 3086, 'github_forks' => 1124, + 'github_watchers' => 480, + 'github_open_issues' => 32, // A dynamic property, causes deprecation warnings in PHP 8.2+ and is now ignored in AbstractResult 'supports_cheese' => true, + 'language' => 'PHP', ]); } @@ -143,4 +146,19 @@ public function it_gets_github_forks() { $this->getGithubForks()->shouldReturn(1124); } + + public function it_gets_github_watchers() + { + $this->getGithubWatchers()->shouldReturn(480); + } + + public function it_gets_github_open_issues() + { + $this->getGithubOpenIssues()->shouldReturn(32); + } + + public function it_gets_language() + { + $this->getLanguage()->shouldReturn('PHP'); + } } diff --git a/src/Packagist/Api/Result/Package.php b/src/Packagist/Api/Result/Package.php index 4bafc96..2c4491c 100644 --- a/src/Packagist/Api/Result/Package.php +++ b/src/Packagist/Api/Result/Package.php @@ -39,6 +39,12 @@ class Package extends AbstractResult protected int $githubForks = 0; + protected int $githubOpenIssues = 0; + + protected int $githubWatchers = 0; + + protected string $language = ''; + public function getName(): string { return $this->name; @@ -132,4 +138,19 @@ public function getGithubForks(): int { return $this->githubForks; } + + public function getGithubWatchers(): int + { + return $this->githubWatchers; + } + + public function getGithubOpenIssues(): int + { + return $this->githubOpenIssues; + } + + public function getLanguage(): string + { + return $this->language; + } } diff --git a/src/Packagist/Api/Result/Package/Maintainer.php b/src/Packagist/Api/Result/Package/Maintainer.php index d9cbdd5..20bbb5c 100644 --- a/src/Packagist/Api/Result/Package/Maintainer.php +++ b/src/Packagist/Api/Result/Package/Maintainer.php @@ -14,6 +14,8 @@ class Maintainer extends AbstractResult protected string $homepage = ''; + protected string $avatarUrl = ''; + public function getName(): string { return $this->name; @@ -28,4 +30,9 @@ public function getHomepage(): string { return $this->homepage; } + + public function getAvatarUrl(): string + { + return $this->avatarUrl; + } } diff --git a/src/Packagist/Api/Result/Package/Version.php b/src/Packagist/Api/Result/Package/Version.php index 110d8bd..6172abe 100644 --- a/src/Packagist/Api/Result/Package/Version.php +++ b/src/Packagist/Api/Result/Package/Version.php @@ -50,6 +50,12 @@ class Version extends AbstractResult protected array $suggest = []; + protected array $support = []; + + protected string $targetDir = ''; + + protected bool $defaultBranch = false; + /** * @var bool|string */ @@ -160,6 +166,21 @@ public function getSuggest(): array return $this->suggest; } + public function getSupport(): array + { + return $this->support; + } + + public function getTargetDir(): string + { + return $this->targetDir; + } + + public function getDefaultBranch(): bool + { + return $this->defaultBranch; + } + public function isAbandoned(): bool { return (bool) $this->abandoned;