8000 Commit status refresh by WyriHaximus · Pull Request #59 · php-api-clients/github · GitHub
[go: up one dir, main page]

Skip to content

Commit status refresh #59

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

Merged
merged 3 commits into from
Oct 11, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Refresh (Combined)Status entities
  • Loading branch information
WyriHaximus committed Oct 11, 2019
commit a23c885830a49af8321157774cae895e7b8daaf5
7 changes: 3 additions & 4 deletions examples/advanced-add-github-sponsors-file.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,10 @@
use ApiClients\Client\Github\Resource\Git\RefInterface;
use ApiClients\Client\Github\Resource\TreeInterface;
use ApiClients\Client\Github\VO\NamedBlob;
use function ApiClients\Tools\Rx\unwrapObservableFromPromise;
use React\EventLoop\Factory;
use React\Stream\ThroughStream;
use Rx\React\Promise;
use function ApiClients\Tools\Rx\unwrapObservableFromPromise;
use function React\Promise\reject;

require \dirname(__DIR__) . \DIRECTORY_SEPARATOR . 'vendor/autoload.php';

Expand All @@ -28,7 +27,7 @@
})->filter(function (Repository $repository) {
return $repository->name() !== 'reactphp-simple-orm';
})->filter(function (Repository $repository) {
return strpos($repository->name(), 'reactphp') !== false;
return \strpos($repository->name(), 'reactphp') !== false;
})->subscribe(function (Repository $repository) use ($argv, $loop) {
$stream = new ThroughStream();

Expand Down Expand Up @@ -66,7 +65,7 @@
return $repository->ref($ref, $commit);
});
})->done(function () use ($repository) {
echo $repository->htmlUrl(), PHP_EOL;
echo $repository->htmlUrl(), \PHP_EOL;
}, 'display_throwable');
}, 'display_throwable');

Expand Down
15 changes: 10 additions & 5 deletions examples/user-repositories-commit-combined-status-async.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,16 @@
return $user->repository($argv[2] ?? 'github');
})->then(function (Repository $repository) {
resource_pretty_print($repository, 1, true);
$repository->commits()->take(1)->subscribe(function (Repository\Commit $commit) {
$commit->status()->done(function (CombinedStatusInterface $combinedStatus) {
resource_pretty_print($combinedStatus, 3, true);
}, 'display_throwable');
}, 'display_throwable');

return $repository->commits()->take(1)->toPromise();
})->then(function (Repository\Commit $commit) {
return $commit->status();
})->then(function (CombinedStatusInterface $combinedStatus) {
resource_pretty_print($combinedStatus, 3, true);

return $combinedStatus->refresh();
})->then(function (CombinedStatusInterface $combinedStatus) {
resource_pretty_print($combinedStatus, 3, true);
})->done(null, 'display_throwable');

$loop->run();
Expand Down
8 changes: 6 additions & 2 deletions src/Resource/Async/Repository/Commit/CombinedStatus.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,16 @@

namespace ApiClients\Client\Github\Resource\Async\Repository\Commit;

use ApiClients\Client\Github\CommandBus\Command\RefreshCommand;
use ApiClients\Client\Github\Resource\Repository\Commit\CombinedStatus as BaseCombinedStatus;
use React\Promise\PromiseInterface;

class CombinedStatus extends BaseCombinedStatus
{
public function refresh(): CombinedStatus
public function refresh(): PromiseInterface
{
throw new \Exception('TODO: create refresh method!');
return $this->handleCommand(
new RefreshCommand($this)
);
}
}
8 changes: 6 additions & 2 deletions src/Resource/Async/Repository/Commit/Status.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,16 @@

namespace ApiClients\Client\Github\Resource\Async\Repository\Commit;

use ApiClients\Client\Github\CommandBus\Command\RefreshCommand;
use ApiClients\Client\Github\Resource\Repository\Commit\Status as BaseStatus;
use React\Promise\PromiseInterface;

class Status extends BaseStatus
{
public function refresh(): Status
public function refresh(): PromiseInterface
{
throw new \Exception('TODO: create refresh method!');
return $this->handleCommand(
new RefreshCommand($this)
);
}
}
13 changes: 13 additions & 0 deletions src/Resource/Repository/Commit/CombinedStatus.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@ abstract class CombinedStatus extends AbstractResource implements CombinedStatus
*/
protected $sha;

/**
* @var string
*/
protected $url;

/**
* @var int
*/
Expand Down Expand Up @@ -59,6 +64,14 @@ public function sha(): string
return $this->sha;
}

/**
* @return string
*/
public function url(): string
{
return $this->url;
}

/**
* @return int
*/
Expand Down
5 changes: 5 additions & 0 deletions src/Resource/Repository/Commit/CombinedStatusInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@ public function state(): string;
*/
public function sha(): string;

/**
* @return string
*/
public function url(): string;

/**
* @return int
*/
Expand Down
8 changes: 8 additions & 0 deletions src/Resource/Repository/Commit/EmptyCombinedStatus.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,14 @@ public function sha(): string
return null;
}

/**
* @return string
*/
public function url(): string
{
return null;
}

/**
* @return int
*/
Expand Down
4 changes: 2 additions & 2 deletions tests/CommandBus/Handler/EmojisHandlerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,14 @@ public function testCommand()
$hydrator = $this->prophesize(Hydrator::class);
$hydrator->hydrate(
EmojiInterface::HYDRATE_CLASS,
[
[
'name' => 'foo',
'image' => 'bar',
]
)->shouldBeCalled()->willReturn($this->prophesize(EmojiInterface::class)->reveal());
$hydrator->hydrate(
EmojiInterface::HYDRATE_CLASS,
[
[
'name' => 'bar',
'image' => 'foo',
]
Expand Down
0