File tree 8 files changed +53
-15
lines changed
8 files changed +53
-15
lines changed Original file line number Diff line number Diff line change 8
8
use ApiClients \Client \Github \Resource \Git \RefInterface ;
9
9
use ApiClients \Client \Github \Resource \TreeInterface ;
10
10
use ApiClients \Client \Github \VO \NamedBlob ;
11
+ use function ApiClients \Tools \Rx \unwrapObservableFromPromise ;
11
12
use React \EventLoop \Factory ;
12
13
use React \Stream \ThroughStream ;
13
14
use Rx \React \Promise ;
14
- use function ApiClients \Tools \Rx \unwrapObservableFromPromise ;
15
- use function React \Promise \reject ;
16
15
17
16
require \dirname (__DIR__ ) . \DIRECTORY_SEPARATOR . 'vendor/autoload.php ' ;
18
17
28
27
})->filter (function (Repository $ repository ) {
29
28
return $ repository ->name () !== 'reactphp-simple-orm ' ;
30
29
})->filter (function (Repository $ repository ) {
31
- return strpos ($ repository ->name (), 'reactphp ' ) !== false ;
30
+ return \ strpos ($ repository ->name (), 'reactphp ' ) !== false ;
32
31
})->subscribe (function (Repository $ repository ) use ($ argv , $ loop ) {
33
32
$ stream = new ThroughStream ();
34
33
66
65
return $ repository ->ref ($ ref , $ commit );
67
66
});
68
67
})->done (function () use ($ repository ) {
69
- echo $ repository ->htmlUrl (), PHP_EOL ;
68
+ echo $ repository ->htmlUrl (), \ PHP_EOL ;
70
69
}, 'display_throwable ' );
71
70
}, 'display_throwable ' );
72
71
Original file line number Diff line number Diff line change 18
18
return $ user ->repository ($ argv [2 ] ?? 'github ' );
19
19
})->then (function (Repository $ repository ) {
20
20
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 );
26
31
})->done (null , 'display_throwable ' );
27
32
28
33
$ loop ->run ();
Original file line number Diff line number Diff line change 2
2
3
3
namespace ApiClients \Client \Github \Resource \Async \Repository \Commit ;
4
4
5
+ use ApiClients \Client \Github \CommandBus \Command \RefreshCommand ;
5
6
use ApiClients \Client \Github \Resource \Repository \Commit \CombinedStatus as BaseCombinedStatus ;
7
+ use React \Promise \PromiseInterface ;
6
8
7
9
class CombinedStatus extends BaseCombinedStatus
8
10
{
9
- public function refresh (): CombinedStatus
11
+ public function refresh (): PromiseInterface
10
12
{
11
- throw new \Exception ('TODO: create refresh method! ' );
13
+ return $ this ->handleCommand (
14
+ new RefreshCommand ($ this )
15
+ );
12
16
}
13
17
}
Original file line number Diff line number Diff line change 2
2
3
3
namespace ApiClients \Client \Github \Resource \Async \Repository \Commit ;
4
4
5
+ use ApiClients \Client \Github \CommandBus \Command \RefreshCommand ;
5
6
use ApiClients \Client \Github \Resource \Repository \Commit \Status as BaseStatus ;
7
+ use React \Promise \PromiseInterface ;
6
8
7
9
class Status extends BaseStatus
8
10
{
9
- public function refresh (): Status
11
+ public function refresh (): PromiseInterface
10
12
{
11
- throw new \Exception ('TODO: create refresh method! ' );
13
+ return $ this ->handleCommand (
14
+ new RefreshCommand ($ this )
15
+ );
12
16
}
13
17
}
Original file line number Diff line number Diff line change @@ -28,6 +28,11 @@ abstract class CombinedStatus extends AbstractResource implements CombinedStatus
28
28
*/
29
29
protected $ sha ;
30
30
31
+ /**
32
+ * @var string
33
+ */
34
+ protected $ url ;
35
+
31
36
/**
32
37
* @var int
33
38
*/
@@ -59,6 +64,14 @@ public function sha(): string
59
64
return $ this ->sha ;
60
65
}
61
66
67
+ /**
68
+ * @return string
69
+ */
70
+ public function url (): string
71
+ {
72
+ return $ this ->url ;
73
+ }
74
+
62
75
/**
63
76
* @return int
64
77
*/
Original file line number Diff line number Diff line change @@ -18,6 +18,11 @@ public function state(): string;
18
18
*/
19
19
public function sha (): string ;
20
20
21
+ /**
22
+ * @return string
23
+ */
24
+ public function url (): string ;
25
+
21
26
/**
22
27
* @return int
23
28
*/
Original file line number Diff line number Diff line change @@ -22,6 +22,14 @@ public function sha(): string
22
22
return null ;
23
23
}
24
24
25
+ /**
26
+ * @return string
27
+ */
28
+ public function url (): string
29
+ {
30
+ return null ;
31
+ }
32
+
25
33
/**
26
34
* @return int
27
35
*/
Original file line number Diff line number Diff line change @@ -29,14 +29,14 @@ public function testCommand()
29
29
$ hydrator = $ this ->prophesize (Hydrator::class);
30
30
$ hydrator ->hydrate (
31
31
EmojiInterface::HYDRATE_CLASS ,
32
- [
32
+ [
33
33
'name ' => 'foo ' ,
34
34
'image ' => 'bar ' ,
35
35
]
36
36
)->shouldBeCalled ()->willReturn ($ this ->prophesize (EmojiInterface::class)->reveal ());
37
37
$ hydrator ->hydrate (
38
38
EmojiInterface::HYDRATE_CLASS ,
39
- [
39
+ [
40
40
'name ' => 'bar ' ,
41
41
'image ' => 'foo ' ,
42
42
]
You can’t perform that action at this time.
0 commit comments