Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add new properties to Package, Version, and Maintainer #98

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions spec/Packagist/Api/Result/Package/MaintainerSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -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',
]);
}

Expand All @@ -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');
}
}
24 changes: 24 additions & 0 deletions spec/Packagist/Api/Result/Package/VersionSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
]);
}

Expand Down Expand Up @@ -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);
}
}
18 changes: 18 additions & 0 deletions spec/Packagist/Api/Result/PackageSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -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',
]);
}

Expand Down Expand Up @@ -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');
}
}
21 changes: 21 additions & 0 deletions src/Packagist/Api/Result/Package.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}
}
7 changes: 7 additions & 0 deletions src/Packagist/Api/Result/Package/Maintainer.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ class Maintainer extends AbstractResult

protected string $homepage = '';

protected string $avatarUrl = '';

public function getName(): string
{
return $this->name;
Expand All @@ -28,4 +30,9 @@ public function getHomepage(): string
{
return $this->homepage;
}

public function getAvatarUrl(): string
{
return $this->avatarUrl;
}
}
21 changes: 21 additions & 0 deletions src/Packagist/Api/Result/Package/Version.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,12 @@ class Version extends AbstractResult

protected array $suggest = [];

protected array $support = [];

protected string $targetDir = '';

protected bool $defaultBranch = false;

/**
* @var bool|string
*/
Expand Down Expand Up @@ -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;
Expand Down
Loading