Skip to content
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
1 change: 1 addition & 0 deletions spec/Packagist/Api/Fixture/get_null_downloads.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"package":{"name":"happyr\/translation-bundle","description":"Integrate Symfony with translations SaaS like http:\/\/localise.biz","time":"2015-08-24T10:02:35+00:00","maintainers":[{"name":"Nyholm","avatar_url":"https:\/\/www.gravatar.com\/avatar\/ab19aada256f3dd9755a7b0152af7023?d=identicon"}],"versions":{"dev-master":{"name":"happyr\/translation-bundle","description":"Integrate Symfony with translations SaaS like http:\/\/localise.biz","keywords":[],"homepage":"http:\/\/developer.happyr.com","version":"dev-master","version_normalized":"dev-master","license":["MIT"],"authors":[{"name":"Tobias Nyholm","email":"[email protected]"}],"source":{"url":"https:\/\/github.com\/Happyr\/TranslationBundle.git","type":"git","reference":"497c042a1b89434b0b874e32c80cec2f5a08cc17"},"dist":{"url":"https:\/\/api.github.com\/repos\/Happyr\/TranslationBundle\/zipball\/497c042a1b89434b0b874e32c80cec2f5a08cc17","type":"zip","shasum":"","reference":"497c042a1b89434b0b874e32c80cec2f5a08cc17"},"type":"symfony-bundle","support":{"issues":"https:\/\/github.com\/Happyr\/TranslationBundle\/issues","source":"https:\/\/github.com\/Happyr\/TranslationBundle\/tree\/master"},"time":"2017-12-17T15:45:48+00:00","autoload":{"psr-4":{"Happyr\\TranslationBundle\\":"src\/"}},"default-branch":true,"require":{"php":"^5.5.9 || ^7.0","symfony\/framework-bundle":"^2.7 || ^3.0","sensio\/framework-extra-bundle":"^2.7 || ^3.0","php-http\/httplug":"^1.0","php-http\/plugins":"^1.0","php-http\/client-implementation":"^1.0","psr\/log":"^1.0"},"require-dev":{"phpunit\/phpunit":"^4.5 || ^5.4","matthiasnoback\/symfony-dependency-injection-test":"^1.0","symfony\/symfony":"^2.3 || ^3.0","php-http\/guzzle6-adapter":"~1.0","php-http\/httplug-bundle":"~1.0"},"suggest":{"php-http\/httplug-bundle":"To easier configure your httplug clients.","happyr\/auto-fallback-translation-bundle":"To automatically translate phrases that are missing form your secondary language."},"abandoned":"php-translation\/symfony-bundle"},"0.4.3":{"name":"happyr\/translation-bundle","description":"Integrate Symfony with translations SaaS like http:\/\/localise.biz","keywords":[],"homepage":"http:\/\/developer.happyr.com","version":"0.4.3","version_normalized":"0.4.3.0","license":["MIT"],"authors":[{"name":"Tobias Nyholm","email":"[email protected]"}],"source":{"url":"https:\/\/github.com\/Happyr\/TranslationBundle.git","type":"git","reference":"acd3b8966764c121e8f2704545bddd716e94babf"},"dist":{"url":"https:\/\/api.github.com\/repos\/Happyr\/TranslationBundle\/zipball\/acd3b8966764c121e8f2704545bddd716e94babf","type":"zip","shasum":"","reference":"acd3b8966764c121e8f2704545bddd716e94babf"},"type":"symfony-bundle","support":{"issues":"https:\/\/github.com\/Happyr\/TranslationBundle\/issues","source":"https:\/\/github.com\/Happyr\/TranslationBundle\/tree\/master"},"time":"2017-06-08T14:46:55+00:00","autoload":{"psr-4":{"Happyr\\TranslationBundle\\":"src\/"}},"require":{"php":"^5.5.9 || ^7.0","symfony\/framework-bundle":"^2.7 || ^3.0","sensio\/framework-extra-bundle":"^2.7 || ^3.0","php-http\/httplug":"^1.0","php-http\/plugins":"^1.0","php-http\/client-implementation":"^1.0","psr\/log":"^1.0"},"require-dev":{"phpunit\/phpunit":"^4.5 || ^5.4","matthiasnoback\/symfony-dependency-injection-test":"^1.0","symfony\/symfony":"^2.3 || ^3.0","php-http\/guzzle6-adapter":"~1.0","php-http\/httplug-bundle":"~1.0"},"suggest":{"php-http\/httplug-bundle":"To easier configure your httplug clients.","happyr\/auto-fallback-translation-bundle":"To automatically translate phrases that are missing form your secondary language."},"abandoned":"php-translation\/symfony-bundle"},"0.4.2":{"name":"happyr\/translation-bundle","description":"Integrate Symfony with translations SaaS like http:\/\/localise.biz","keywords":[],"homepage":"http:\/\/developer.happyr.com","version":"0.4.2","version_normalized":"0.4.2.0","license":["MIT"],"authors":[{"name":"Tobias Nyholm","email":"[email protected]"}],"source":{"url":"https:\/\/github.com\/Happyr\/TranslationBundle.git","type":"git","reference":"e4145af8e29a33a09bbe4874bee94dd6135fb1f6"},"dist":{"url":"https:\/\/api.github.com\/repos\/Happyr\/TranslationBundle\/zipball\/e4145af8e29a33a09bbe4874bee94dd6135fb1f6","type":"zip","shasum":"","reference":"e4145af8e29a33a09bbe4874bee94dd6135fb1f6"},"type":"symfony-bundle","support":{"issues":"https:\/\/github.com\/Happyr\/TranslationBundle\/issues","source":"https:\/\/github.com\/Happyr\/TranslationBundle\/tree\/master"},"time":"2016-04-23T08:23:26+00:00","autoload":{"psr-4":{"Happyr\\TranslationBundle\\":"src\/"}},"require":{"php":"\u003E=5.5.9","symfony\/symfony":"~2.7|~3.0","sensio\/framework-extra-bundle":"~2.7|~3.0","php-http\/httplug":"^1.0","php-http\/plugins":"^1.0","php-http\/client-implementation":"^1.0","psr\/log":"^1.0"},"require-dev":{"php-http\/guzzle6-adapter":"~1.0","php-http\/httplug-bundle":"~1.0"},"suggest":{"php-http\/httplug-bundle":"To easier configure your httplug clients.","happyr\/auto-fallback-translation-bundle":"To automatically translate phrases that are missing form your secondary language."},"abandoned":"php-translation\/symfony-bundle"},"0.4.1":{"name":"happyr\/translation-bundle","description":"Integrate Symfony with translations SaaS like http:\/\/localise.biz","keywords":[],"homepage":"http:\/\/developer.happyr.com","version":"0.4.1","version_normalized":"0.4.1.0","license":["MIT"],"authors":[{"name":"Tobias Nyholm","email":"[email protected]"}],"source":{"url":"https:\/\/github.com\/Happyr\/TranslationBundle.git","type":"git","reference":"18440e14c20130076730589030966d40a78f6618"},"dist":{"url":"https:\/\/api.github.com\/repos\/Happyr\/TranslationBundle\/zipball\/18440e14c20130076730589030966d40a78f6618","type":"zip","shasum":"","reference":"18440e14c20130076730589030966d40a78f6618"},"type":"symfony-bundle","support":{"issues":"https:\/\/github.com\/Happyr\/TranslationBundle\/issues","source":"https:\/\/github.com\/Happyr\/TranslationBundle\/tree\/master"},"time":"2016-04-18T07:53:32+00:00","autoload":{"psr-4":{"Happyr\\TranslationBundle\\":"src\/"}},"require":{"php":"\u003E=5.5.9","symfony\/symfony":"~2.7|~3.0","sensio\/framework-extra-bundle":"~2.7|~3.0","php-http\/httplug":"^1.0","php-http\/plugins":"^1.0","php-http\/client-implementation":"^1.0","psr\/log":"^1.0"},"require-dev":{"php-http\/guzzle6-adapter":"~1.0"},"suggest":{"php-http\/httplug-bundle":"To easier configure your httplug clients.","happyr\/auto-fallback-translation-bundle":"To automatically translate phrases that are missing form your secondary language."},"abandoned":"php-translation\/symfony-bundle"},"0.4.0":{"name":"happyr\/translation-bundle","description":"Integrate Symfony with translations SaaS like http:\/\/localise.biz","keywords":[],"homepage":"http:\/\/developer.happyr.com","version":"0.4.0","version_normalized":"0.4.0.0","license":["MIT"],"authors":[{"name":"Tobias Nyholm","email":"[email protected]"}],"source":{"url":"https:\/\/github.com\/Happyr\/TranslationBundle.git","type":"git","reference":"f787049394efe6e1755ba3c69d57fcb5c1364eb3"},"dist":{"url":"https:\/\/api.github.com\/repos\/Happyr\/TranslationBundle\/zipball\/f787049394efe6e1755ba3c69d57fcb5c1364eb3","type":"zip","shasum":"","reference":"f787049394efe6e1755ba3c69d57fcb5c1364eb3"},"type":"symfony-bundle","support":{"issues":"https:\/\/github.com\/Happyr\/TranslationBundle\/issues","source":"https:\/\/github.com\/Happyr\/TranslationBundle\/tree\/master"},"time":"2016-04-17T19:49:26+00:00","autoload":{"psr-4":{"Happyr\\TranslationBundle\\":"src\/"}},"require":{"php":"\u003E=5.5.9","symfony\/symfony":"~2.7|~3.0","sensio\/framework-extra-bundle":"~2.7|~3.0","php-http\/httplug":"^1.0","php-http\/plugins":"^1.0","php-http\/client-implementation":"^1.0","psr\/log":"^1.0"},"require-dev":{"php-http\/guzzle6-adapter":"~1.0"},"suggest":{"php-http\/httplug-bundle":"To easier configure your httplug clients.","happyr\/auto-fallback-translation-bundle":"To automatically translate phrases that are missing form your secondary language."},"abandoned":"php-translation\/symfony-bundle"},"0.3.0":{"name":"happyr\/translation-bundle","description":"Integrate Symfony with translations SaaS like http:\/\/localise.biz","keywords":[],"homepage":"http:\/\/developer.happyr.com","version":"0.3.0","version_normalized":"0.3.0.0","license":["MIT"],"authors":[{"name":"Tobias Nyholm","email":"[email protected]"}],"source":{"url":"https:\/\/github.com\/Happyr\/TranslationBundle.git","type":"git","reference":"a13d16e185554fab1afcd90237a4bc57b9bc7d12"},"dist":{"url":"https:\/\/api.github.com\/repos\/Happyr\/TranslationBundle\/zipball\/a13d16e185554fab1afcd90237a4bc57b9bc7d12","type":"zip","shasum":"","reference":"a13d16e185554fab1afcd90237a4bc57b9bc7d12"},"type":"symfony-bundle","support":{"issues":"https:\/\/github.com\/Happyr\/TranslationBundle\/issues","source":"https:\/\/github.com\/Happyr\/TranslationBundle\/tree\/master"},"time":"2016-02-25T08:44:34+00:00","autoload":{"psr-4":{"Happyr\\TranslationBundle\\":"src\/"}},"require":{"php":"\u003E=5.5.9","symfony\/symfony":"~2.7|~3.0","sensio\/framework-extra-bundle":"~2.7|~3.0","php-http\/httplug":"^1.0","php-http\/plugins":"^1.0","php-http\/client-implementation":"^1.0","psr\/log":"^1.0"},"require-dev":{"php-http\/guzzle6-adapter":"~1.0"},"suggest":{"php-http\/httplug-bundle":"To easier configure your httplug clients.","happyr\/auto-fallback-translation-bundle":"To automatically translate phrases that are missing form your secondary language."},"abandoned":"php-translation\/symfony-bundle"},"0.2.2":{"name":"happyr\/translation-bundle","description":"Integrate Symfony with translations SaaS like http:\/\/localise.biz","keywords":[],"homepage":"http:\/\/developer.happyr.com","version":"0.2.2","version_normalized":"0.2.2.0","license":["MIT"],"authors":[{"name":"Tobias Nyholm","email":"[email protected]"}],"source":{"url":"https:\/\/github.com\/Happyr\/TranslationBundle.git","type":"git","reference":"fbae4cfe3c31ed0c45eca2aaef2be10ababdaee0"},"dist":{"url":"https:\/\/api.github.com\/repos\/Happyr\/TranslationBundle\/zipball\/fbae4cfe3c31ed0c45eca2aaef2be10ababdaee0","type":"zip","shasum":"","reference":"fbae4cfe3c31ed0c45eca2aaef2be10ababdaee0"},"type":"symfony-bundle","support":{"issues":"https:\/\/github.com\/Happyr\/TranslationBundle\/issues","source":"https:\/\/github.com\/Happyr\/TranslationBundle\/tree\/master"},"time":"2016-01-04T11:11:56+00:00","autoload":{"psr-4":{"Happyr\\TranslationBundle\\":"src\/"}},"require":{"php":"\u003E=5.5.9","symfony\/symfony":"~2.7|~3.0","sensio\/framework-extra-bundle":"~2.7|~3.0","php-http\/httplug":"1.0.0-beta","php-http\/discovery":"^0.4|^0.5","php-http\/plugins":"dev-master","php-http\/client-implementation":"1.0","psr\/log":"1.0.0"},"require-dev":{"php-http\/guzzle5-adapter":"dev-master"},"abandoned":"php-translation\/symfony-bundle"},"0.2.1":{"name":"happyr\/translation-bundle","description":"Integrate Symfony with translations SaaS like http:\/\/localise.biz","keywords":[],"homepage":"http:\/\/developer.happyr.com","version":"0.2.1","version_normalized":"0.2.1.0","license":["MIT"],"authors":[{"name":"Tobias Nyholm","email":"[email protected]"}],"source":{"url":"https:\/\/github.com\/Happyr\/TranslationBundle.git","type":"git","reference":"9ffd5b2d2966b3bd4aa8e3e2a2296b17e464470e"},"dist":{"url":"https:\/\/api.github.com\/repos\/Happyr\/TranslationBundle\/zipball\/9ffd5b2d2966b3bd4aa8e3e2a2296b17e464470e","type":"zip","shasum":"","reference":"9ffd5b2d2966b3bd4aa8e3e2a2296b17e464470e"},"type":"symfony-bundle","support":{"issues":"https:\/\/github.com\/Happyr\/TranslationBundle\/issues","source":"https:\/\/github.com\/Happyr\/TranslationBundle\/tree\/master"},"time":"2015-12-23T18:39:02+00:00","autoload":{"psr-4":{"Happyr\\TranslationBundle\\":"src\/"}},"require":{"php":"\u003E=5.5.9","symfony\/symfony":"~2.7|~3.0","sensio\/framework-extra-bundle":"~2.7|~3.0","php-http\/httplug":"1.0.0-beta","php-http\/discovery":"^0.4","php-http\/plugins":"dev-master","php-http\/client-implementation":"1.0","psr\/log":"1.0.0"},"require-dev":{"php-http\/guzzle5-adapter":"dev-master"},"abandoned":"php-translation\/symfony-bundle"},"0.2.0":{"name":"happyr\/translation-bundle","description":"Integrate Symfony with translations SaaS like http:\/\/localise.biz","keywords":[],"homepage":"http:\/\/developer.happyr.com","version":"0.2.0","version_normalized":"0.2.0.0","license":["MIT"],"authors":[{"name":"Tobias Nyholm","email":"[email protected]"}],"source":{"url":"https:\/\/github.com\/Happyr\/TranslationBundle.git","type":"git","reference":"f55e3862ea30fd24f4737d8046be7b6a7a6cd9ab"},"dist":{"url":"https:\/\/api.github.com\/repos\/Happyr\/TranslationBundle\/zipball\/f55e3862ea30fd24f4737d8046be7b6a7a6cd9ab","type":"zip","shasum":"","reference":"f55e3862ea30fd24f4737d8046be7b6a7a6cd9ab"},"type":"symfony-bundle","support":{"issues":"https:\/\/github.com\/Happyr\/TranslationBundle\/issues","source":"https:\/\/github.com\/Happyr\/TranslationBundle\/tree\/master"},"time":"2015-12-23T18:20:01+00:00","autoload":{"psr-4":{"Happyr\\TranslationBundle\\":"src\/"}},"require":{"php":"\u003E=5.5.9","symfony\/symfony":"~2.7|~3.0","sensio\/framework-extra-bundle":"~2.7|~3.0","php-http\/httplug":"1.0.0-beta","php-http\/discovery":"^0.4","php-http\/plugins":"dev-master","php-http\/client-implementation":"1.0","psr\/log":"1.0.0"},"require-dev":{"php-http\/guzzle5-adapter":"dev-master"},"abandoned":"php-translation\/symfony-bundle"},"0.1.0":{"name":"happyr\/translation-bundle","description":"Integrate Symfony with translations SaaS like http:\/\/localise.biz","keywords":[],"homepage":"http:\/\/developer.happyr.com","version":"0.1.0","version_normalized":"0.1.0.0","license":["MIT"],"authors":[{"name":"Tobias Nyholm","email":"[email protected]"}],"source":{"url":"https:\/\/github.com\/Happyr\/TranslationBundle.git","type":"git","reference":"94b1202aaa7aeac253c9bf9ef5a7038b5768b296"},"dist":{"url":"https:\/\/api.github.com\/repos\/Happyr\/TranslationBundle\/zipball\/94b1202aaa7aeac253c9bf9ef5a7038b5768b296","type":"zip","shasum":"","reference":"94b1202aaa7aeac253c9bf9ef5a7038b5768b296"},"type":"symfony-bundle","support":{"issues":"https:\/\/github.com\/Happyr\/TranslationBundle\/issues","source":"https:\/\/github.com\/Happyr\/TranslationBundle\/tree\/master"},"time":"2015-12-23T16:20:42+00:00","autoload":{"psr-0":{"Happyr\\TranslationBundle\\":""}},"target-dir":"Happyr\/TranslationBundle","require":{"php":"\u003E=5.5.9","symfony\/symfony":"~2.7|~3.0","sensio\/framework-extra-bundle":"~2.7|~3.0","guzzlehttp\/guzzle":"~5.3|~6.0"},"abandoned":"php-translation\/symfony-bundle"}},"type":"symfony-bundle","repository":"https:\/\/github.com\/Happyr\/TranslationBundle","github_stars":52,"github_watchers":9,"github_forks":24,"github_open_issues":9,"language":"PHP","abandoned":"php-translation\/symfony-bundle","dependents":1,"suggesters":0,"downloads":null,"favers":null}}
33 changes: 20 additions & 13 deletions spec/Packagist/Api/Result/FactorySpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@

class FactorySpec extends ObjectBehavior
{
public function it_is_initializable()
public function it_is_initializable(): void
{
$this->shouldHaveType(Factory::class);
}

public function it_creates_search_results()
public function it_creates_search_results(): void
{
$data = json_decode(file_get_contents('spec/Packagist/Api/Fixture/search.json'), true);

Expand All @@ -28,7 +28,7 @@ public function it_creates_search_results()
}
}

public function it_creates_popular_results()
public function it_creates_popular_results(): void
{
$data = json_decode(file_get_contents('spec/Packagist/Api/Fixture/popular.json'), true);

Expand Down Expand Up @@ -71,15 +71,15 @@ public function it_creates_composer_releases_packages(): void
$results->shouldHaveCount(1);
$results->shouldBeArray();
foreach ($results as $result) {
$result->shouldBeAnInstanceOf('Packagist\Api\Result\Package');
$result->shouldBeAnInstanceOf(Package::class);

foreach ($result->getVersions() as $version) {
$version->shouldBeAnInstanceOf('Packagist\Api\Result\Version');
$version->shouldBeAnInstanceOf(Package\Version::class);
}
}
}

public function it_creates_package_names()
public function it_creates_package_names(): void
{
$data = json_decode(file_get_contents('spec/Packagist/Api/Fixture/all.json'), true);

Expand All @@ -90,46 +90,54 @@ public function it_creates_package_names()
]);
}

public function it_creates_packages_with_missing_optional_data()
public function it_creates_packages_with_missing_optional_data(): void
{
$data = json_decode(file_get_contents('spec/Packagist/Api/Fixture/get_nodist.json'), true);

$this->create($data)->shouldHaveType(Package::class);
}

public function it_creates_abandoned_packages()
public function it_creates_abandoned_packages(): void
{
$data = json_decode(file_get_contents('spec/Packagist/Api/Fixture/get_abandoned.json'), true);

$this->create($data)->shouldHaveType(Package::class);
}

public function it_creates_packages_with_suggesters()
public function it_creates_packages_with_suggesters(): void
{
$data = json_decode(file_get_contents('spec/Packagist/Api/Fixture/get_suggesters.json'), true);
$this->create($data)->shouldHaveType(Package::class);
}

public function it_creates_packages_with_dependents()
public function it_creates_packages_with_dependents(): void
{
$data = json_decode(file_get_contents('spec/Packagist/Api/Fixture/get_dependents.json'), true);
$this->create($data)->shouldHaveType(Package::class);
}

public function it_creates_packages_with_null_source()
public function it_creates_packages_with_null_source(): void
{
$data = json_decode(file_get_contents('spec/Packagist/Api/Fixture/get_null_source.json'), true);
$this->create($data)->shouldHaveType(Package::class);
}

public function it_creates_packages_with_null_description()
public function it_creates_packages_with_null_description(): void
{
$data = json_decode(file_get_contents('spec/Packagist/Api/Fixture/get_null_description.json'), true);
$result = $this->create($data);
$result->shouldHaveType(Package::class);
$result->getDescription()->shouldBe('');
}

public function it_creates_packages_with_null_downloads(): void
{
$data = json_decode(file_get_contents('spec/Packagist/Api/Fixture/get_null_downloads.json'), true);
$result = $this->create($data);
$result->shouldHaveType(Package::class);
$result->getDownloads()->shouldBeNull();
}

public function getMatchers(): array
{
return array(
Expand All @@ -138,5 +146,4 @@ public function getMatchers(): array
}
);
}

}
3 changes: 2 additions & 1 deletion src/Packagist/Api/Result/Factory.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ public function createPackageResults(array $package): Package
$package['github_forks'] ??= 0;
$package['suggesters'] ??= 0;
$package['dependents'] ??= 0;
$package['downloads'] ??= null;
$package['favers'] ??= 0;

if (isset($package['maintainers']) && $package['maintainers']) {
Expand All @@ -115,7 +116,7 @@ public function createPackageResults(array $package): Package
}
}

if (isset($package['downloads']) && $package['downloads']) {
if (isset($package['downloads']) && is_array($package['downloads'])) {
$package['downloads'] = $this->createResult(Downloads::class, $package['downloads']);
}

Expand Down
4 changes: 2 additions & 2 deletions src/Packagist/Api/Result/Package.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class Package extends AbstractResult

protected string $repository = '';

protected Downloads $downloads;
protected ?Downloads $downloads;

protected int $favers = 0;

Expand Down Expand Up @@ -80,7 +80,7 @@ public function getRepository(): string
return $this->repository;
}

public function getDownloads(): Downloads
public function getDownloads(): ?Downloads
{
return $this->downloads;
}
Expand Down