Skip to content
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

refactor: Complete models attributes #66

Merged
merged 15 commits into from
Jun 26, 2024
107 changes: 27 additions & 80 deletions src/Model/Card.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,128 +56,75 @@ protected function fill(object $data): void
}
}

/**
* @var string|null
*/
public $illustrator;
public ?string $illustrator = null;

/**
* @var string
*/
public $rarity;
public string $rarity = '';

/**
* @var string
*/
public $category;
public string $category = '';

/**
* @var Variants
*/
public $variants;
public Variants $variants;

/**
* @var SetResume
*/
public $set;
public SetResume $set;

/**
* @var int[]|null
* @var int[]
*/
public $dexId;
public ?array $dexId = null;

/**
* @var int|null
*/
public $hp;
/**
* @var string[]|null
*/
public $types;
public ?int $hp = null;

/**
* @var string|null
* @var string[]
*/
public $evolveFrom;
public ?array $types = null;

public ?string $evolveFrom = null;

/**
* Temporarly not implemented due to #28
*/
// public $weight;
// public $height;

/**
* @var string|null
*/
public $description;
public ?string $description = null;

/**
* @var string|int|null
*/
public $level;
public string|int|null $level = null;

/**
* @var string|null
*/
public $stage;
public ?string $stage = null;

/**
* @var string|null
*/
public $suffix;
public ?string $suffix = null;

/**
* @var Item|null
*/
public $item;
public ?Item $item = null;

/**
* @var Ability[]
*/
public $abilities;
public array $abilities = [];

/**
* @var Attack[]
*/
public $attacks;
public array $attacks = [];

/**
* @var WeakRes[]
*/
public $weaknesses;
public array $weaknesses = [];

/**
* @var WeakRes[]
*/
public $resistances;
public array $resistances = [];

/**
* @var int|null
*/
public $retreat;
public ?int $retreat = null;

/**
* @var string|null
*/
public $effect;
public ?string $effect = null;

/**
* @var string|null
*/
public $trainerType;
public ?string $trainerType = null;

/**
* @var string|null
*/
public $energyType;
public ?string $energyType = null;

/**
* @var string|null
*/
public $regulationMark;
public ?string $regulationMark = null;

/**
* @var Legal
*/
public $legal;
public Legal $legal;
}
20 changes: 4 additions & 16 deletions src/Model/CardResume.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,13 @@

class CardResume extends Model
{
/**
* @var string
*/
public $id;
public string $id = '';

/**
* @var string
*/
public $localId;
public string $localId = '';

/**
* @var string
*/
public $name;
public string $name = '';

/**
* @var string|null
*/
public $image;
public ?string $image = null;

/**
* @deprecated 2.2.0 use `toCard()` instead
Expand Down
12 changes: 4 additions & 8 deletions src/Model/Model.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,13 @@

namespace TCGdex\Model;

use TCGdex\TCGdex;

abstract class Model
{
/**
* @var \TCGdex\TCGdex
*/
protected $sdk;
protected TCGdex $sdk;

/**
* @param \TCGdex\TCGdex $sdk
*/
public function __construct(&$sdk)
public function __construct(TCGdex $sdk)
{
$this->sdk = $sdk;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Model/Serie.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ class Serie extends SerieResume
/**
* @var SetResume[]
*/
public $sets;
public array $sets = [];

protected function fill(object $data): void
{
Expand Down
18 changes: 3 additions & 15 deletions src/Model/SerieResume.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,11 @@

class SerieResume extends Model
{
/**
* @var string
*/
public $id;
public string $id = '';

/**
* @var string
*/
public $name;
public string $name = '';

/**
* @var string|null
*/
public $logo;
public ?string $logo = null;

/**
* @deprecated 2.2.0 use `toSerie()` instead
Expand All @@ -27,9 +18,6 @@ public function fetchFullSerie(): Serie
return $this->toSerie();
}

/**
* @return Serie
*/
public function toSerie(): Serie
{
return $this->sdk->serie->get($this->id);
Expand Down
28 changes: 6 additions & 22 deletions src/Model/Set.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,31 +8,15 @@

class Set extends SetResume
{
/**
* @var SerieResume
*/
public $serie;
public SerieResume $serie;

/**
* @var string|null
*/
public $tcgOnline;
public ?string $tcgOnline = null;

public ?Variants $variants = null;

/**
* @var Variants|null
*/
public $variants;
public string $releaseDate = '';

/**
* @var string
*/
public $releaseDate;

/**
* @var Legal
*/
public $legal;
public Legal $legal;

/**
* @var CardCount
Expand All @@ -42,7 +26,7 @@ class Set extends SetResume
/**
* @var CardResume[]
*/
public $cards;
public array $cards = [];

protected function fill(object $data): void
{
Expand Down
23 changes: 4 additions & 19 deletions src/Model/SetResume.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,25 +6,13 @@

class SetResume extends Model
{
/**
* @var string
*/
public $id;
public string $id = '';

/**
* @var string
*/
public $name;
public string $name = '';

/**
* @var string|null
*/
public $logo;
public ?string $logo = null;

/**
* @var string|null
*/
public $symbol;
public ?string $symbol = null;

/**
* @var CardCountResume
Expand All @@ -42,9 +30,6 @@ protected function fill(object $data): void
}
}

/**
* @return Set
*/
public function toSet(): Set
{
return $this->sdk->set->get($this->id);
Expand Down
17 changes: 7 additions & 10 deletions src/Model/StringEndpoint.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@

class StringEndpoint extends Model
{
public string $name = '';

/**
* @var CardResume[]
*/
public array $cards = [];

protected function fill(object $data): void
{
foreach ($data as $key => $value) {
Expand All @@ -16,14 +23,4 @@ protected function fill(object $data): void
}
}
}

/**
* @var string
*/
public $name;

/**
* @var \TCGdex\Model\CardResume[]
*/
public $cards;
}
15 changes: 3 additions & 12 deletions src/Model/SubModel/Ability.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,9 @@

class Ability extends Model
{
/**
* @var string
*/
public $type;
public string $type = '';

/**
* @var string
*/
public $name;
public string $name = '';

/**
* @var string
*/
public $effect;
public string $effect = '';
}
Loading