8000 Refresh (Combined)Status entities · php-api-clients/github@a23c885 · GitHub
[go: up one dir, main page]

Skip to content

Commit a23c885

Browse files
committed
Refresh (Combined)Status entities
1 parent 923c338 commit a23c885

File tree

8 files changed

+53
-15
lines changed

8 files changed

+53
-15
lines changed

examples/advanced-add-github-sponsors-file.php

+3-4
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,10 @@
88
use ApiClients\Client\Github\Resource\Git\RefInterface;
99
use ApiClients\Client\Github\Resource\TreeInterface;
1010
use ApiClients\Client\Github\VO\NamedBlob;
11+
use function ApiClients\Tools\Rx\unwrapObservableFromPromise;
1112
use React\EventLoop\Factory;
1213
use React\Stream\ThroughStream;
1314
use Rx\React\Promise;
14-
use function ApiClients\Tools\Rx\unwrapObservableFromPromise;
15-
use function React\Promise\reject;
1615

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

@@ -28,7 +27,7 @@
2827
})->filter(function (Repository $repository) {
2928
return $repository->name() !== 'reactphp-simple-orm';
3029
})->filter(function (Repository $repository) {
31-
return strpos($repository->name(), 'reactphp') !== false;
30+
return \strpos($repository->name(), 'reactphp') !== false;
3231
})->subscribe(function (Repository $repository) use ($argv, $loop) {
3332
$stream = new ThroughStream();
3433

@@ -66,7 +65,7 @@
6665
return $repository->ref($ref, $commit);
6766
});
6867
})->done(function () use ($repository) {
69-
echo $repository->htmlUrl(), PHP_EOL;
68+
echo $repository->htmlUrl(), \PHP_EOL;
7069
}, 'display_throwable');
7170
}, 'display_throwable');
7271

examples/user-repositories-commit-combined-status-async.php

+10-5
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,16 @@
1818
return $user->repository($argv[2] ?? 'github');
1919
})->then(function (Repository $repository) {
2020
resource_pretty_print($repository, 1, true);
21-
$repository->commits()->take(1)->subscribe(function (Repository\Commit $commit) {
22-
$commit->status()->done(function (CombinedStatusInterface $combinedStatus) {
23-
resource_pretty_print($combinedStatus, 3, true);
24-
}, 'display_throwable');
25-
}, 'display_throwable');
21+
22+
return $repository->commits()->take(1)->toPromise();
23+
})->then(function (Repository\Commit $commit) {
24+
return $commit->status();
25+
})->then(function (CombinedStatusInterface $combinedStatus) {
26+
resource_pretty_print($combinedStatus, 3, true);
27+
28+
return $combinedStatus->refresh();
29+
})->then(function (CombinedStatusInterface $combinedStatus) {
30+
resource_pretty_print($combinedStatus, 3, true);
2631
})->done(null, 'display_throwable');
2732

2833
$loop->run();

src/Resource/Async/Repository/Commit/CombinedStatus.php

+6-2
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,16 @@
22

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

5+
use ApiClients\Client\Github\CommandBus\Command\RefreshCommand;
56
use ApiClients\Client\Github\Resource\Repository\Commit\CombinedStatus as BaseCombinedStatus;
7+
use React\Promise\PromiseInterface;
68

79
class CombinedStatus extends BaseCombinedStatus
810
{
9-
public function refresh(): CombinedStatus
11+
public function refresh(): PromiseInterface
1012
{
11-
throw new \Exception('TODO: create refresh method!');
13+
return $this->handleCommand(
14+
new RefreshCommand($this)
15+
);
1216
}
1317
}

src/Resource/Async/Repository/Commit/Status.php

+6-2
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,16 @@
22

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

5+
use ApiClients\Client\Github\CommandBus\Command\RefreshCommand;
56
use ApiClients\Client\Github\Resource\Repository\Commit\Status as BaseStatus;
7+
use React\Promise\PromiseInterface;
68

79
class Status extends BaseStatus
810
{
9-
public function refresh(): Status
11+
public function refresh(): PromiseInterface
1012
{
11-
throw new \Exception('TODO: create refresh method!');
13+
return $this->handleCommand(
14+
new RefreshCommand($this)
15+
);
1216
}
1317
}

src/Resource/Repository/Commit/CombinedStatus.php

+13
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,11 @@ abstract class CombinedStatus extends AbstractResource implements CombinedStatus
2828
*/
2929
protected $sha;
3030

31+
/**
32+
* @var string
33+
*/
34+
protected $url;
35+
3136
/**
3237
* @var int
3338
*/
@@ -59,6 +64,14 @@ public function sha(): string
5964
return $this->sha;
6065
}
6166

67+
/**
68+
* @return string
69+
*/
70+
public function url(): string
71+
{
72+
return $this->url;
73+
}
74+
6275
/**
6376
* @return int
6477
*/

src/Resource/Repository/Commit/CombinedStatusInterface.php

+5
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,11 @@ public function state(): string;
1818
*/
1919
public function sha(): string;
2020

21+
/**
22+
* @return string
23+
*/
24+
public function url(): string;
25+
2126
/**
2227
* @return int
2328
*/

src/Resource/Repository/Commit/EmptyCombinedStatus.php

+8
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,14 @@ public function sha(): string
2222
return null;
2323
}
2424

25+
/**
26+
* @return string
27+
*/
28+
public function url(): string
29+
{
30+
return null;
31+
}
32+
2533
/**
2634
* @return int
2735
*/

tests/CommandBus/Handler/EmojisHandlerTest.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,14 @@ public function testCommand()
2929
$hydrator = $this->prophesize(Hydrator::class);
3030
$hydrator->hydrate(
3131
EmojiInterface::HYDRATE_CLASS,
32-
[
32+
[
3333
'name' => 'foo',
3434
'image' => 'bar',
3535
]
3636
)->shouldBeCalled()->willReturn($this->prophesize(EmojiInterface::class)->reveal());
3737
$hydrator->hydrate(
3838
EmojiInterface::HYDRATE_CLASS,
39-
[
39+
[
4040
'name' => 'bar',
4141
'image' => 'foo',
4242
]

0 commit comments

Comments
 (0)
0