-
Notifications
You must be signed in to change notification settings - Fork 0
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
ca1212b
commit 5972081
Showing
10 changed files
with
172 additions
and
169 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
This file was deleted.
Oops, something went wrong.
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,55 @@ | ||
<?php | ||
|
||
namespace ProgrammatorDev\SportMonksFootball\Resource; | ||
|
||
use ProgrammatorDev\SportMonksFootball\Entity\Response\TypeCollection; | ||
use ProgrammatorDev\SportMonksFootball\Entity\Response\TypeEntityCollection; | ||
use ProgrammatorDev\SportMonksFootball\Entity\Response\TypeItem; | ||
use ProgrammatorDev\SportMonksFootball\Resource\Util\PaginationTrait; | ||
use Psr\Http\Client\ClientExceptionInterface; | ||
|
||
class TypeResource extends Resource | ||
{ | ||
use PaginationTrait; | ||
|
||
/** | ||
* @throws ClientExceptionInterface | ||
*/ | ||
public function getAll(): TypeCollection | ||
{ | ||
$data = $this->api->request( | ||
method: 'GET', | ||
path: '/v3/core/types' | ||
); | ||
|
||
return new TypeCollection($data); | ||
} | ||
|
||
/** | ||
* @throws ClientExceptionInterface | ||
*/ | ||
public function getById(int $id): TypeItem | ||
{ | ||
$data = $this->api->request( | ||
method: 'GET', | ||
path: $this->api->buildPath('/v3/core/types/{id}', [ | ||
'id' => $id | ||
]) | ||
); | ||
|
||
return new TypeItem($data); | ||
} | ||
|
||
/** | ||
* @throws ClientExceptionInterface | ||
*/ | ||
public function getAllByEntity(): TypeEntityCollection | ||
{ | ||
$data = $this->api->request( | ||
method: 'GET', | ||
path: '/v3/core/types/entities' | ||
); | ||
|
||
return new TypeEntityCollection($data); | ||
} | ||
} |
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
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,44 @@ | ||
<?php | ||
|
||
namespace ProgrammatorDev\SportMonksFootball\Test\Integration; | ||
|
||
use ProgrammatorDev\SportMonksFootball\Entity\Response\TypeCollection; | ||
use ProgrammatorDev\SportMonksFootball\Entity\Response\TypeEntityCollection; | ||
use ProgrammatorDev\SportMonksFootball\Entity\Response\TypeItem; | ||
use ProgrammatorDev\SportMonksFootball\Test\AbstractTest; | ||
use ProgrammatorDev\SportMonksFootball\Test\MockResponse; | ||
use ProgrammatorDev\SportMonksFootball\Test\Util\TestCollectionResponseTrait; | ||
use ProgrammatorDev\SportMonksFootball\Test\Util\TestItemResponseTrait; | ||
|
||
class TypeResourceTest extends AbstractTest | ||
{ | ||
use TestItemResponseTrait; | ||
use TestCollectionResponseTrait; | ||
|
||
public static function provideItemResponseData(): \Generator | ||
{ | ||
yield 'get by id' => [ | ||
TypeItem::class, | ||
MockResponse::TYPE_ITEM_DATA, | ||
'types', | ||
'getById', | ||
[1] | ||
]; | ||
} | ||
|
||
public static function provideCollectionResponseData(): \Generator | ||
{ | ||
yield 'get all' => [ | ||
TypeCollection::class, | ||
MockResponse::TYPE_COLLECTION_DATA, | ||
'types', | ||
'getAll' | ||
]; | ||
yield 'get all by entity' => [ | ||
TypeEntityCollection::class, | ||
MockResponse::TYPE_ENTITY_COLLECTION_DATA, | ||
'types', | ||
'getAllByEntity' | ||
]; | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
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 | ||
|
||
namespace ProgrammatorDev\SportMonksFootball\Test\Unit; | ||
|
||
use ProgrammatorDev\SportMonksFootball\Entity\Type; | ||
use ProgrammatorDev\SportMonksFootball\Entity\TypeEntity; | ||
use ProgrammatorDev\SportMonksFootball\Test\AbstractTest; | ||
|
||
class TypeEntityTest extends AbstractTest | ||
{ | ||
public function testMethods(): void | ||
{ | ||
$entity = new TypeEntity([ | ||
'_key' => 'PlayerStatisticDetail', | ||
'updated_at' => '2024-01-01 16:00:00', | ||
'types' => [ | ||
[ | ||
'id' => 1, | ||
'name' => '1st Half', | ||
'code' => '1st-half', | ||
'developer_name' => '1ST_HALF', | ||
'model_type' => 'period', | ||
'stat_group' => 'overall' | ||
] | ||
] | ||
]); | ||
|
||
$this->assertSame('PlayerStatisticDetail', $entity->getName()); | ||
$this->assertInstanceOf(\DateTimeImmutable::class, $entity->getUpdatedAt()); | ||
$this->assertContainsOnlyInstancesOf(Type::class, $entity->getTypes()); | ||
} | ||
} |
Oops, something went wrong.