Skip to content
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
4 changes: 2 additions & 2 deletions Dockerfile → .docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM php:8.1
FROM php:8.4

WORKDIR /usr/src/app

Expand All @@ -15,7 +15,7 @@ RUN apt-get update \
# && docker-php-ext-install pdo mysqli pdo_mysql zip intl gd

# Copy the PHP config
# COPY php.ini /usr/local/etc/php/php.ini
COPY php.ini /usr/local/etc/php/php.ini

# Copy composer
COPY --from=composer:2 /usr/bin/composer /usr/bin/composer
9 changes: 9 additions & 0 deletions .docker/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Command to run from the project root :
# docker-compose -f .docker/docker-compose.yml run --build dev /bin/bash
services:
dev:
build: .
stdin_open: true
tty: true
volumes:
- ..:/usr/src/app
2 changes: 2 additions & 0 deletions .docker/php.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
display_errors = On
error_reporting = E_ALL | E_DEPRECATED | E_NOTICE
3 changes: 1 addition & 2 deletions .github/workflows/build-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,11 @@ on:

jobs:
build:

runs-on: ubuntu-latest
strategy:
matrix:
# follows https://www.php.net/supported-versions.php
php-versions: ['8.1', '8.2', '8.3']
php-versions: ['8.1', '8.2', '8.3', '8.4']
phpunit-versions: ['latest']

steps:
Expand Down
9 changes: 0 additions & 9 deletions docker-compose.yml

This file was deleted.

10 changes: 4 additions & 6 deletions phpunit.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,22 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd"
backupGlobals="true"
backupStaticAttributes="false"
bootstrap="vendor/autoload.php"
cacheResult="false"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
forceCoversAnnotation="false"
processIsolation="false"
stopOnError="true"
stopOnFailure="false"
stopOnIncomplete="false"
stopOnSkipped="false"
stopOnRisky="false"
displayDetailsOnTestsThatTriggerDeprecations="true"
displayDetailsOnTestsThatTriggerErrors="true"
displayDetailsOnTestsThatTriggerNotices="true"
displayDetailsOnTestsThatTriggerWarnings="true"
timeoutForSmallTests="1"
timeoutForMediumTests="10"
timeoutForLargeTests="60"
verbose="false"
>
<coverage>
<include>
Expand Down
8 changes: 7 additions & 1 deletion src/Endpoints/Endpoint.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,17 @@ public function __construct(
}

/**
* @return Item
* @return Item|null
*/
public function get(string|int $id)
{
$res = $this->tcgdex->fetch($this->endpoint, $id);

// handle case where result is not defined or an error
if (is_null($res)) {
return null;
}

return Model::build(new $this->itemModel($this->tcgdex), $res);
}

Expand Down
5 changes: 5 additions & 0 deletions src/Model/Serie.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,18 @@ class Serie extends SerieResume
*/
public array $sets = [];

public ?SetResume $firstSet = null;
public ?SetResume $lastSet = null;

protected function fill(object $data): void
{
foreach ($data as $key => $value) {
if ($key === 'sets') {
$this->sets = array_map(function ($item) {
return Model::build(new SetResume($this->sdk), $item);
}, $value);
} elseif ($key === 'firstSet' || $key === 'lastSet') {
$this->{$key} = Model::build(new SetResume($this->sdk), $value);
} else {
$this->{$key} = $value;
}
Expand Down
30 changes: 28 additions & 2 deletions src/Model/Set.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,51 @@
use TCGdex\Model\SubModel\CardCount;
use TCGdex\Model\SubModel\Variants;
use TCGdex\Model\SubModel\Legal;
use TCGdex\Model\SubModel\Abbreviation;

class Set extends SetResume
{
/**
* the serie the set is part of
*/
public SerieResume $serie;

/**
* the TCG Online ID
*/
public ?string $tcgOnline = null;

/**
* @deprecated this variable is inexistant in the API
*/
public ?Variants $variants = null;

/**
* the set release date as an ISO8601 string (ex: `2020-02-01`)
*/
public string $releaseDate = '';

/**
* Designate if the set is usable in tournaments
*
* Note: this is specific to the set and if a
* card is banned from the set it will still be true
*/
public Legal $legal;

/**
* the number of cards of the set in total & by variant
* @var CardCount
*/
public $cardCount;

/**
* The official and localized abbreviation used by TPC
*/
public Abbreviation $abbreviation;

/**
* the list of cards of the set
* @var CardResume[]
*/
public array $cards = [];
Expand All @@ -35,8 +61,8 @@ protected function fill(object $data): void
$this->cardCount = Model::build(new CardCount($this->sdk), $value);
} elseif ($key === 'serie') {
$this->serie = Model::build(new SerieResume($this->sdk), $value);
} elseif ($key === 'variants') {
$this->variants = Model::build(new Variants($this->sdk), $value);
} elseif ($key === 'abbreviation') {
$this->abbreviation = Model::build(new Abbreviation($this->sdk), $value);
} elseif ($key === 'legal') {
$this->legal = Model::build(new Legal($this->sdk), $value);
} elseif ($key === 'cards') {
Expand Down
11 changes: 11 additions & 0 deletions src/Model/SubModel/Abbreviation.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?php

namespace TCGdex\Model\SubModel;

use TCGdex\Model\Model;

class Abbreviation extends Model
{
public ?string $official = null;
public ?string $localized = null;
}
12 changes: 12 additions & 0 deletions src/Model/SubModel/CardCount.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,23 @@

class CardCount extends CardCountResume
{
/**
* number of cards having a normal version
*/
public int $normal = 0;

/**
* number of cards having an reverse version
*/
public int $reverse = 0;

/**
* number of cards having an holo version
*/
public int $holo = 0;

/**
* Number of cards that can have the first edition tag
*/
public ?int $firstEd = null;
}
6 changes: 6 additions & 0 deletions src/Model/SubModel/CardCountResume.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,13 @@

class CardCountResume extends Model
{
/**
* total of number of cards
*/
public int $total = 0;

/**
* number of cards officialy (on the bottom of each cards)
*/
public int $official = 0;
}
6 changes: 6 additions & 0 deletions src/Model/SubModel/Legal.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,13 @@

class Legal extends Model
{
/**
* Ability to play in standard tournaments
*/
public bool $standard;

/**
* Ability to play in expanded tournaments
*/
public bool $expanded;
}
2 changes: 1 addition & 1 deletion tests/TCGdexDeprecatedTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ final class TCGdexDeprecatedTest extends TestCase
{
public function testCanRequest(): void
{
TCGdex::$client = new Psr18Mock("{\"ok\": true}");
TCGdex::$client = new Psr18Mock("{\"id\": \"swsh1-136\"}");
$tcgdex = new TCGdex("en");
$card = $tcgdex->fetchCard('testCanRequest');
$this->assertNotEmpty($card);
Expand Down
2 changes: 1 addition & 1 deletion tests/TCGdexTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ final class TCGdexTest extends TestCase

public function testCanRequest(): void
{
TCGdex::$client = new Psr18Mock("{\"ok\": true}");
TCGdex::$client = new Psr18Mock("{\"id\": \"swsh1-136\"}");
$tcgdex = new TCGdex("en");
$card = $tcgdex->card->get('testCanRequest');
$this->assertNotEmpty($card);
Expand Down
Loading