File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 88use ApiClients \Client \Github \Resource \Git \RefInterface ;
99use ApiClients \Client \Github \Resource \TreeInterface ;
1010use ApiClients \Client \Github \VO \NamedBlob ;
11+ use function ApiClients \Tools \Rx \unwrapObservableFromPromise ;
1112use React \EventLoop \Factory ;
1213use React \Stream \ThroughStream ;
1314use Rx \React \Promise ;
14- use function ApiClients \Tools \Rx \unwrapObservableFromPromise ;
15- use function React \Promise \reject ;
1615
1716require \dirname (__DIR__ ) . \DIRECTORY_SEPARATOR . 'vendor/autoload.php ' ;
1817
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
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
Original file line number Diff line number Diff line change 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 ();
Original file line number Diff line number Diff line change 22
33namespace ApiClients \Client \Github \Resource \Async \Repository \Commit ;
44
5+ use ApiClients \Client \Github \CommandBus \Command \RefreshCommand ;
56use ApiClients \Client \Github \Resource \Repository \Commit \CombinedStatus as BaseCombinedStatus ;
7+ use React \Promise \PromiseInterface ;
68
79class 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}
Original file line number Diff line number Diff line change 22
33namespace ApiClients \Client \Github \Resource \Async \Repository \Commit ;
44
5+ use ApiClients \Client \Github \CommandBus \Command \RefreshCommand ;
56use ApiClients \Client \Github \Resource \Repository \Commit \Status as BaseStatus ;
7+ use React \Promise \PromiseInterface ;
68
79class 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}
Original file line number Diff line number Diff 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 */
Original file line number Diff line number Diff 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 */
Original file line number Diff line number Diff 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 */
Original file line number Diff line number Diff 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 ]
You can’t perform that action at this time.
0 commit comments