diff --git a/README.md b/README.md index 1dba9506f5..c487f5e85f 100644 --- a/README.md +++ b/README.md @@ -7,16 +7,13 @@ [![License](https://poser.pugx.org/api-clients/github/license.png)](https://packagist.org/packages/api-clients/github) [![PHP 7 ready](http://php7ready.timesplinter.ch/php-api-clients/github/badge.svg)](https://travis-ci.org/php-api-clients/github) -# Goals - -* 100% Github [API](https://developer.github.com/v3/) support -* Both synchronous and asynchronous +The branch contains the work for the next generation of this package. [The old branch containing v0.1.0 can be found here.](https://github.com/php-api-clients/github/tree/master) # License The MIT License (MIT) -Copyright (c) 2016 Cees-Jan Kiewiet +Copyright (c) 2021 Cees-Jan Kiewiet Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/composer.json b/composer.json index 23df9b4c37..c4a1628d3b 100644 --- a/composer.json +++ b/composer.json @@ -51,6 +51,10 @@ "sort-packages": true, "platform": { "php": "7.3.3" + }, + "allow-plugins": { + "ocramius/package-versions": true, + "localheinz/composer-normalize": true } }, "extra": { diff --git a/src/CommandBus/Handler/Repository/Commit/ChecksHandler.php b/src/CommandBus/Handler/Repository/Commit/ChecksHandler.php index bf3ddfb3b8..451c915e5b 100644 --- a/src/CommandBus/Handler/Repository/Commit/ChecksHandler.php +++ b/src/CommandBus/Handler/Repository/Commit/ChecksHandler.php @@ -3,22 +3,20 @@ namespace ApiClients\Client\Github\CommandBus\Handler\Repository\Commit; use ApiClients\Client\Github\CommandBus\Command\Repository\Commit\ChecksCommand; -use ApiClients\Client\Github\CommandBus\Command\Repository\Commit\StatusesCommand; use ApiClients\Client\Github\Resource\Repository\Commit\CheckInterface; -use ApiClients\Client\Github\Resource\Repository\Commit\StatusInterface; use ApiClients\Client\Github\Service\IteratePagesService; use ApiClients\Foundation\Hydrator\Hydrator; -use ApiClients\Tools\Services\Client\FetchAndIterateService; use function ApiClients\Tools\Rx\observableFromArray; use React\Promise\PromiseInterface; use function React\Promise\resolve; +use function igorw\get_in; final class ChecksHandler { /** - * @var FetchAndIterateService + * @var IteratePagesService */ - private $fetchAndIterateService; + private $iteratePagesService; /** * @var Hydrator @@ -26,12 +24,12 @@ final class ChecksHandler private $hydrator; /** - * @param FetchAndIterateService $fetchAndIterateService + * @param IteratePagesService $iteratePagesService * @param Hydrator $hydrator */ - public function __construct(FetchAndIterateService $fetchAndIterateService, Hydrator $hydrator) + public function __construct(IteratePagesService $iteratePagesService, Hydrator $hydrator) { - $this->fetchAndIterateService = $fetchAndIterateService; + $this->iteratePagesService = $iteratePagesService; $this->hydrator = $hydrator; } @@ -42,11 +40,12 @@ public function __construct(FetchAndIterateService $fetchAndIterateService, Hydr public function handle(ChecksCommand $command): PromiseInterface { return resolve( - $this->fetchAndIterateService->iterate( - $command->getCommit()->url() . '/check-runs', - 'check_runs', - CheckInterface::HYDRATE_CLASS - ) + $this->iteratePagesService->iterate($command->getCommit()->url() . '/check-runs',) + ->flatMap(function ($checkRuns) { + return observableFromArray(get_in($checkRuns, ['check_runs'], [])); + })->map(function ($checkRun) { + return $this->hydrator->hydrate(CheckInterface::HYDRATE_CLASS, $checkRun); + }) ); } }