Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c17ad1a
commit f97c370
Showing
24 changed files
with
673 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
<?php declare(strict_types=1); | ||
|
||
namespace ApiClients\Client\Github\CommandBus\Command\Repository; | ||
|
||
use WyriHaximus\Tactician\CommandHandler\Annotations\Handler; | ||
|
||
/** | ||
* @Handler("ApiClients\Client\Github\CommandBus\Handler\Repository\RefsHandler") | ||
*/ | ||
final class RefsCommand | ||
{ | ||
/** @var string */ | ||
private $fullName; | ||
|
||
/** @var string|null */ | ||
private $namespace; | ||
|
||
/** | ||
* @param string $fullName | ||
* @param string|null $namespace | ||
*/ | ||
public function __construct(string $fullName, ?string $namespace) | ||
{ | ||
$this->fullName = $fullName; | ||
$this->namespace = $namespace; | ||
} | ||
|
||
/** | ||
* @return string | ||
*/ | ||
public function getFullName(): string | ||
{ | ||
return $this->fullName; | ||
} | ||
|
||
/** | ||
* @return string | ||
*/ | ||
public function getNamespace(): ?string | ||
{ | ||
return $this->namespace; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
<?php declare(strict_types=1); | ||
|
||
namespace ApiClients\Client\Github\CommandBus\Handler\Repository; | ||
|
||
use ApiClients\Client\Github\CommandBus\Command\Repository\RefsCommand; | ||
use ApiClients\Client\Github\Resource\Git\RefInterface; | ||
use ApiClients\Client\Github\Service\IteratePagesService; | ||
use ApiClients\Foundation\Hydrator\Hydrator; | ||
use function ApiClients\Tools\Rx\observableFromArray; | ||
use React\Promise\PromiseInterface; | ||
use function React\Promise\resolve; | ||
|
||
final class RefsHandler | ||
{ | ||
/** | ||
* @var IteratePagesService | ||
*/ | ||
private $iteratePagesService; | ||
|
||
/** | ||
* @var Hydrator | ||
*/ | ||
private $hydrator; | ||
|
||
/** | ||
* @param IteratePagesService $iteratePagesService | ||
* @param Hydrator $hydrator | ||
*/ | ||
public function __construct(IteratePagesService $iteratePagesService, Hydrator $hydrator) | ||
{ | ||
$this->iteratePagesService = $iteratePagesService; | ||
$this->hydrator = $hydrator; | ||
} | ||
|
||
/** | ||
* @param RefsCommand $command | ||
* @return PromiseInterface | ||
*/ | ||
public function handle(RefsCommand $command): PromiseInterface | ||
{ | ||
$namespace = !empty($command->getNamespace()) ? '/' . $command->getNamespace() : ''; | ||
|
||
return resolve( | ||
$this->iteratePagesService->iterate('repos/' . $command->getFullName() . '/git/refs' . $namespace) | ||
->flatMap(function ($commits) { | ||
return observableFromArray($commits); | ||
})->map(function ($commit) { | ||
return $this->hydrator->hydrate(RefInterface::HYDRATE_CLASS, $commit); | ||
}) | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<?php declare(strict_types=1); | ||
|
||
namespace ApiClients\Client\Github\Resource\Async\Git; | ||
|
||
use ApiClients\Client\Github\Resource\Git\EmptyRef as BaseEmptyRef; | ||
|
||
class EmptyRef extends BaseEmptyRef | ||
{ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<?php declare(strict_types=1); | ||
|
||
namespace ApiClients\Client\Github\Resource\Async\Git; | ||
|
||
use ApiClients\Client\Github\Resource\Git\Ref as BaseRef; | ||
|
||
class Ref extends BaseRef | ||
{ | ||
public function refresh(): Ref | ||
{ | ||
throw new \Exception('TODO: create refresh method!'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<?php declare(strict_types=1); | ||
|
||
namespace ApiClients\Client\Github\Resource\Git; | ||
|
||
use ApiClients\Foundation\Resource\EmptyResourceInterface; | ||
|
||
abstract class EmptyRef implements RefInterface, EmptyResourceInterface | ||
{ | ||
/** | ||
* @return string | ||
*/ | ||
public function ref(): string | ||
{ | ||
return null; | ||
} | ||
|
||
/** | ||
* @return string | ||
*/ | ||
public function url(): string | ||
{ | ||
return null; | ||
} | ||
|
||
/** | ||
* @return Git\Ref\Object_ | ||
*/ | ||
public function author(): Git\Ref\Object_ | ||
{ | ||
return null; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
<?php declare(strict_types=1); | ||
|
||
namespace ApiClients\Client\Github\Resource\Git; | ||
|
||
use ApiClients\Foundation\Hydrator\Annotation\EmptyResource; | ||
use ApiClients\Foundation\Hydrator\Annotation\Nested; | ||
use ApiClients\Foundation\Resource\AbstractResource; | ||
|
||
/** | ||
* @Nested( | ||
* author="Git\Ref\Object_" | ||
* ) | ||
* @EmptyResource("Git\EmptyRef") | ||
*/ | ||
abstract class Ref extends AbstractResource implements RefInterface | ||
{ | ||
/** | ||
* @var string | ||
*/ | ||
protected $ref; | ||
|
||
/** | ||
* @var string | ||
*/ | ||
protected $url; | ||
|
||
/** | ||
* @var Git\Ref\Object_ | ||
*/ | ||
protected $author; | ||
|
||
/** | ||
* @return string | ||
*/ | ||
public function ref(): string | ||
{ | ||
return $this->ref; | ||
} | ||
|
||
/** | ||
* @return string | ||
*/ | ||
public function url(): string | ||
{ | ||
return $this->url; | ||
} | ||
|
||
/** | ||
* @return Git\Ref\Object_ | ||
*/ | ||
public function author(): Git\Ref\Object_ | ||
{ | ||
return $this->author; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<?php declare(strict_types=1); | ||
|
||
namespace ApiClients\Client\Github\Resource\Git\Ref; | ||
|
||
use ApiClients\Foundation\Resource\EmptyResourceInterface; | ||
|
||
abstract class EmptyObject_ implements Object_Interface, EmptyResourceInterface | ||
{ | ||
/** | ||
* @return string | ||
*/ | ||
public function type(): string | ||
{ | ||
return null; | ||
} | ||
|
||
/** | ||
* @return string | ||
*/ | ||
public function sha(): string | ||
{ | ||
return null; | ||
} | ||
|
||
/** | ||
* @return string | ||
*/ | ||
public function url(): string | ||
{ | ||
return null; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
<?php declare(strict_types=1); | ||
|
||
namespace ApiClients\Client\Github\Resource\Git\Ref; | ||
|
||
use ApiClients\Foundation\Hydrator\Annotation\EmptyResource; | ||
use ApiClients\Foundation\Resource\AbstractResource; | ||
|
||
/** | ||
* @EmptyResource("Git\Ref\EmptyObject_") | ||
*/ | ||
abstract class Object_ extends AbstractResource implements Object_Interface | ||
{ | ||
/** | ||
* @var string | ||
*/ | ||
protected $type; | ||
|
||
/** | ||
* @var string | ||
*/ | ||
protected $sha; | ||
|
||
/** | ||
* @var string | ||
*/ | ||
protected $url; | ||
|
||
/** | ||
* @return string | ||
*/ | ||
public function type(): string | ||
{ | ||
return $this->type; | ||
} | ||
|
||
/** | ||
* @return string | ||
*/ | ||
public function sha(): string | ||
{ | ||
return $this->sha; | ||
} | ||
|
||
/** | ||
* @return string | ||
*/ | ||
public function url(): string | ||
{ | ||
return $this->url; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<?php declare(strict_types=1); | ||
|
||
namespace ApiClients\Client\Github\Resource\Git\Ref; | ||
|
||
use ApiClients\Foundation\Resource\ResourceInterface; | ||
|
||
interface Object_Interface extends ResourceInterface | ||
{ | ||
const HYDRATE_CLASS = 'Git\\Ref\\Object_'; | ||
|
||
/** | ||
* @return string | ||
*/ | ||
public function type(): string; | ||
|
||
/** | ||
* @return string | ||
*/ | ||
public function sha(): string; | ||
|
||
/** | ||
* @return string | ||
*/ | ||
public function url(): string; | ||
} |
Oops, something went wrong.