Skip to content

Get files from commit #66

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 1 commit into from
Oct 17, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
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
7 changes: 5 additions & 2 deletions examples/user-repositories-commits-async.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
use ApiClients\Client\Github\AsyncClient;
use ApiClients\Client\Github\Resource\Async\Repository;
use ApiClients\Client\Github\Resource\Async\User;
use ApiClients\Client\Github\Resource\Repository\Commit;
use function ApiClients\Foundation\resource_pretty_print;
use React\EventLoop\Factory;

Expand All @@ -17,8 +18,10 @@
return $user->repository($argv[2] ?? 'github');
})->then(function (Repository $repository) {
resource_pretty_print($repository, 1, true);
$repository->commits()->subscribe(function ($commit) {
resource_pretty_print($commit, 2, true);
$repository->commits()->take(1)->subscribe(function (Repository\Commit $commit) {
$commit->refresh()->then(function (Commit $commit) {
resource_pretty_print($commit, 2, true);
});
}, 'display_throwable');
})->done(null, 'display_throwable');

Expand Down
9 changes: 9 additions & 0 deletions src/Resource/Async/Repository/Commit/EmptyFile.php
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\Repository\Commit;

use ApiClients\Client\Github\Resource\Repository\Commit\EmptyFile as BaseEmptyFile;

class EmptyFile extends BaseEmptyFile
{
}
13 changes: 13 additions & 0 deletions src/Resource/Async/Repository/Commit/File.php
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\Repository\Commit;

use ApiClients\Client\Github\Resource\Repository\Commit\File as BaseFile;

class File extends BaseFile
{
public function refresh(): File
{
throw new \Exception('TODO: create refresh method!');
}
}
16 changes: 15 additions & 1 deletion src/Resource/Repository/Commit.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@

/**
* @Collection(
* parents="Tree"
* parents="Tree",
* files="Repository\Commit\File"
* )
* @Nested(
* commit="Git\Commit",
Expand Down Expand Up @@ -60,6 +61,11 @@ abstract class Commit extends AbstractResource implements CommitInterface
*/
protected $parents;

/**
* @var Commit\File[]
*/
protected $files;

/**
* @return string
*/
Expand Down Expand Up @@ -115,4 +121,12 @@ public function parents(): array
{
return $this->parents;
}

/**
* @return Commit\File[]
*/
public function files(): array
{
return $this->files;
}
}
72 changes: 72 additions & 0 deletions src/Resource/Repository/Commit/EmptyFile.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
<?php declare(strict_types=1);

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

use ApiClients\Foundation\Resource\EmptyResourceInterface;

abstract class EmptyFile implements FileInterface, EmptyResourceInterface
{
/**
* @return string
*/
public function filename(): string
{
return null;
}

/**
* @return int
*/
public function additions(): int
{
return null;
}

/**
* @return int
*/
public function deletions(): int
{
return null;
}

/**
* @return int
*/
public function changes(): int
{
return null;
}

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

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

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

/**
* @return string
*/
public function patch(): string
{
return null;
}
}
116 changes: 116 additions & 0 deletions src/Resource/Repository/Commit/File.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
<?php declare(strict_types=1);

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

use ApiClients\Foundation\Hydrator\Annotation\EmptyResource;
use ApiClients\Foundation\Resource\AbstractResource;

/**
* @EmptyResource("Repository\Commit\EmptyFile")
*/
abstract class File extends AbstractResource implements FileInterface
{
/**
* @var string
*/
protected $filename;

/**
* @var int
*/
protected $additions;

/**
* @var int
*/
protected $deletions;

/**
* @var int
*/
protected $changes;

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

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

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

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

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

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

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

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

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

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

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

/**
* @return string
*/
public function patch(): string
{
return $this->patch;
}
}
50 changes: 50 additions & 0 deletions src/Resource/Repository/Commit/FileInterface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<?php declare(strict_types=1);

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

use ApiClients\Foundation\Resource\ResourceInterface;

interface FileInterface extends ResourceInterface
{
const HYDRATE_CLASS = 'Repository\\Commit\\File';

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

/**
* @return int
*/
public function additions(): int;

/**
* @return int
*/
public function deletions(): int;

/**
* @return int
*/
public function changes(): int;

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

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

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

/**
* @return string
*/
public function patch(): string;
}
27 changes: 16 additions & 11 deletions src/Resource/Repository/EmptyCommit.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@

namespace ApiClients\Client\Github\Resource\Repository;

use ApiClients\Client\Github\Resource\Git\CommitInterface as GitCommitInterface;
use ApiClients\Client\Github\Resource\TreeInterface;
use ApiClients\Client\Github\Resource\UserInterface;
use ApiClients\Foundation\Resource\EmptyResourceInterface;

abstract class EmptyCommit implements CommitInterface, EmptyResourceInterface
Expand Down Expand Up @@ -34,33 +31,41 @@ public function htmlUrl(): string
}

/**
* @return GitCommitInterface
* @return Git\Commit
*/
public function commit(): GitCommitInterface
public function commit(): Git\Commit
{
return null;
}

/**
* @return UserInterface
* @return User
*/
public function author(): UserInterface
public function author(): User
{
return null;
}

/**
* @return UserInterface
* @return User
*/
public function comitter(): UserInterface
public function comitter(): User
{
return null;
}

/**
* @return TreeInterface
* @return Tree
*/
public function parents(): TreeInterface
public function parents(): Tree
{
return null;
}

/**
* @return Repository\Commit\File
*/
public function files(): Repository\Commit\File
{
return null;
}
Expand Down
9 changes: 9 additions & 0 deletions src/Resource/Sync/Repository/Commit/EmptyFile.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?php declare(strict_types=1);

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

use ApiClients\Client\Github\Resource\Repository\Commit\EmptyFile as BaseEmptyFile;

class EmptyFile extends BaseEmptyFile
{
}
Loading