Card
extends Part
in package
uses
CardAttributes
Represents a Magic: The Gathering card (one object from the API's `cards` response); {@see CardAttributes} declares the raw API fields and this class adds the collections and Discord render helpers.
Tags
Table of Contents
Properties
- $foreignNames : ExCollectionInterface<string|int, ForeignName>
- $image_embed : Embed|null
- $legalities : ExCollectionInterface<string|int, Legality>
- $rulings : ExCollectionInterface<string|int, Ruling>
- $fillable : mixed
Methods
- getArtist() : string|null
- Gets the name of the artist who illustrated the card.
- getCmc() : int
- Gets the converted mana cost of the card.
- getColorIdentity() : array<string|int, string>|null
- Gets the color identity of the card.
- getColors() : array<string|int, string>|null
- Gets the colors of the card.
- getContains() : string|null
- Gets the "contains" field filter.
- getFlavor() : string|null
- Gets the card's flavor text.
- getForeignNamesAttribute() : ExCollectionInterface<string|int, ForeignName>
- Gets the foreign names of the card.
- getForeignNamesButton() : Button|null
- Gets a button to view the foreign names for the card.
- getGameFormat() : string|null
- Gets the game format used to filter legality.
- getId() : string|null
- Gets the card's unique id.
- getImageEmbedAttribute() : Embed|null
- Generates an Embed object for the card's image.
- getJsonButton() : Button|null
- Gets a button to view the raw JSON of the card.
- getLanguage() : string|null
- Gets the language used when querying foreign card names.
- getLayout() : string|null
- Gets the layout of the card.
- getLegalitiesAttribute() : ExCollectionInterface<string|int, Legality>
- Gets the legality of the card.
- getLegalitiesButton() : Button|null
- Gets a button to view the legal formats for the card.
- getLegality() : string|null
- Gets the legality status used to filter results.
- getLoyalty() : int|null
- Gets the planeswalker's starting loyalty.
- getMultiverseid() : int|null
- Gets the card's Gatherer multiverse id.
- getName() : string|null
- Gets the name of the card.
- getNumber() : string|null
- Gets the card's collector number within its set.
- getOrderBy() : string|null
- Gets the field results are ordered by.
- getPage() : int|null
- Gets the results page number.
- getPageSize() : int|null
- Gets the number of results per page.
- getPower() : string|null
- Gets the creature's power.
- getRandom() : bool|null
- Gets whether a random card was requested.
- getRarity() : string|null
- Gets the rarity of the card.
- getReleaseDateAttribute() : ?Carbon|null
- Gets the release date of the card.
- getRulingsAttribute() : ExCollectionInterface<string|int, Ruling>
- Converts the card to a container with components.
- getRulingsButton() : Button|null
- Builds a button that, when clicked, replies with this card's rulings grouped by date. Returns null when the card has no rulings.
- getSet() : string|null
- Gets the code of the set the card belongs to.
- getSetButton() : Button|null
- Gets a button to view the set the card belongs to.
- getSetName() : string|null
- Gets the full name of the set the card belongs to.
- getSubtypes() : array<string|int, string>|null
- Gets the subtypes of the card.
- getSupertypes() : array<string|int, string>|null
- Gets the supertypes of the card.
- getText() : string|null
- Gets the card's oracle rules text.
- getToughness() : string|null
- Gets the creature's toughness.
- getType() : string|null
- Gets the type of the card.
- getTypes() : array<string|int, string>|null
- Gets the types of the card.
- getViewImageButton() : Button|null
- Gets a button to view the image of the card.
- normalLayoutContainer() : Container
- Builds and returns a Container representing the normal layout for a Magic: The Gathering card.
- setArtist() : self
- Sets the name of the artist who illustrated the card.
- setCmc() : $this
- Sets the converted mana cost of the card.
- setColorIdentity() : $this
- Sets the color identity of the card.
- setColors() : $this
- Sets the colors of the card.
- setContains() : self
- Restricts results to cards that have the named field(s) present.
- setFlavor() : self
- Sets the card's flavor text.
- setGameFormat() : self
- Sets the game format to filter legality against (e.g. "Standard", "Modern").
- setId() : self
- Sets the card's unique id (a hash of set code, name and collector number).
- setLanguage() : self
- Sets the language to match foreign card names against when querying.
- setLayout() : $this
- Sets the layout of the card.
- setLegality() : self
- Sets the legality status to filter by ("Legal", "Banned" or "Restricted").
- setLoyalty() : self
- Sets the planeswalker's starting loyalty.
- setMultiverseid() : self
- Sets the card's Gatherer multiverse id.
- setName() : $this
- Sets the name of the card.
- setNumber() : self
- Sets the card's collector number within its set.
- setOrderBy() : self
- Sets the field to order results by.
- setPage() : self
- Sets the results page number to request (1-based pagination).
- setPageSize() : self
- Sets the number of results per page.
- setPower() : self
- Sets the creature's power. A string because it may be non-numeric (e.g. "*").
- setRandom() : self
- Requests a single random card matching the other filters. Only a truthy value has an effect; `false`/`null` leaves the flag unset.
- setRarity() : self
- Sets the rarity of the card (e.g. "Common", "Rare", "Mythic Rare").
- setSet() : self
- Sets the code of the set the card belongs to.
- setSetName() : self
- Sets the full name of the set the card belongs to.
- setSubtypes() : self
- Sets the subtypes of the card (e.g. "Human", "Wizard", "Equipment").
- setSupertypes() : $this
- Sets the supertypes of the card.
- setText() : self
- Sets the card's oracle rules text.
- setToughness() : self
- Sets the creature's toughness. A string because it may be non-numeric (e.g. "*").
- setType() : $this
- Sets the type of the card.
- setTypes() : self
- Sets the types of the card.
- toContainer() : Container|null
- Converts the card to a container with components.
Properties
$foreignNames
public
ExCollectionInterface<string|int, ForeignName>
$foreignNames
$image_embed read-only
public
Embed|null
$image_embed
The card image as an embed, or null when the card has no imageUrl.
$legalities
public
ExCollectionInterface<string|int, Legality>
$legalities
$rulings
public
ExCollectionInterface<string|int, Ruling>
$rulings
$fillable
protected
mixed
$fillable
= [
'name',
'layout',
'cmc',
'colors',
'colorIdentity',
'type',
'supertypes',
'types',
'subtypes',
'rarity',
'set',
// Short name
'setName',
// Full name, can be used to query /sets
'text',
'flavor',
'artist',
'number',
'power',
'toughness',
'loyalty',
'language',
'gameFormat',
'legality',
'page',
'pageSize',
'orderBy',
'random',
'contains',
'id',
'multiverseid',
// The fields below are also part of the response (if not null), but cannot currently be used as query parameters
'names',
'manaCost',
'variations',
'imageUrl',
'watermark',
'border',
'timeshifted',
'hand',
'life',
'reserved',
'releaseDate',
'starter',
'rulings',
'foreignNames',
'printings',
'originalText',
'originalType',
'legalities',
'source',
]
Tags
Methods
getArtist()
Gets the name of the artist who illustrated the card.
public
getArtist() : string|null
Return values
string|nullgetCmc()
Gets the converted mana cost of the card.
public
getCmc() : int
Return values
intgetColorIdentity()
Gets the color identity of the card.
public
getColorIdentity() : array<string|int, string>|null
Return values
array<string|int, string>|nullgetColors()
Gets the colors of the card.
public
getColors() : array<string|int, string>|null
Return values
array<string|int, string>|nullgetContains()
Gets the "contains" field filter.
public
getContains() : string|null
Return values
string|nullgetFlavor()
Gets the card's flavor text.
public
getFlavor() : string|null
Return values
string|nullgetForeignNamesAttribute()
Gets the foreign names of the card.
public
getForeignNamesAttribute() : ExCollectionInterface<string|int, ForeignName>
Tags
Return values
ExCollectionInterface<string|int, ForeignName>getForeignNamesButton()
Gets a button to view the foreign names for the card.
public
getForeignNamesButton(Interaction $interaction) : Button|null
Parameters
- $interaction : Interaction
Tags
Return values
Button|nullgetGameFormat()
Gets the game format used to filter legality.
public
getGameFormat() : string|null
Return values
string|nullgetId()
Gets the card's unique id.
public
getId() : string|null
Return values
string|nullgetImageEmbedAttribute()
Generates an Embed object for the card's image.
public
getImageEmbedAttribute() : Embed|null
Tags
Return values
Embed|nullgetJsonButton()
Gets a button to view the raw JSON of the card.
public
getJsonButton(Interaction|null $interaction) : Button|null
Parameters
- $interaction : Interaction|null
Tags
Return values
Button|nullgetLanguage()
Gets the language used when querying foreign card names.
public
getLanguage() : string|null
Return values
string|nullgetLayout()
Gets the layout of the card.
public
getLayout() : string|null
Return values
string|nullgetLegalitiesAttribute()
Gets the legality of the card.
public
getLegalitiesAttribute() : ExCollectionInterface<string|int, Legality>
Tags
Return values
ExCollectionInterface<string|int, Legality>getLegalitiesButton()
Gets a button to view the legal formats for the card.
public
getLegalitiesButton(Interaction $interaction) : Button|null
Parameters
- $interaction : Interaction
Tags
Return values
Button|nullgetLegality()
Gets the legality status used to filter results.
public
getLegality() : string|null
Return values
string|nullgetLoyalty()
Gets the planeswalker's starting loyalty.
public
getLoyalty() : int|null
Return values
int|nullgetMultiverseid()
Gets the card's Gatherer multiverse id.
public
getMultiverseid() : int|null
Return values
int|nullgetName()
Gets the name of the card.
public
getName() : string|null
Return values
string|nullgetNumber()
Gets the card's collector number within its set.
public
getNumber() : string|null
Return values
string|nullgetOrderBy()
Gets the field results are ordered by.
public
getOrderBy() : string|null
Return values
string|nullgetPage()
Gets the results page number.
public
getPage() : int|null
Return values
int|nullgetPageSize()
Gets the number of results per page.
public
getPageSize() : int|null
Return values
int|nullgetPower()
Gets the creature's power.
public
getPower() : string|null
Return values
string|nullgetRandom()
Gets whether a random card was requested.
public
getRandom() : bool|null
Return values
bool|nullgetRarity()
Gets the rarity of the card.
public
getRarity() : string|null
Return values
string|nullgetReleaseDateAttribute()
Gets the release date of the card.
public
getReleaseDateAttribute() : ?Carbon|null
Tags
Return values
?Carbon|nullgetRulingsAttribute()
Converts the card to a container with components.
public
getRulingsAttribute() : ExCollectionInterface<string|int, Ruling>
Tags
Return values
ExCollectionInterface<string|int, Ruling>getRulingsButton()
Builds a button that, when clicked, replies with this card's rulings grouped by date. Returns null when the card has no rulings.
public
getRulingsButton(Interaction $interaction) : Button|null
Parameters
- $interaction : Interaction
-
The interaction the button will belong to.
Return values
Button|nullgetSet()
Gets the code of the set the card belongs to.
public
getSet() : string|null
Return values
string|nullgetSetButton()
Gets a button to view the set the card belongs to.
public
getSetButton([Interaction|null $interaction = null ]) : Button|null
Parameters
- $interaction : Interaction|null = null
Tags
Return values
Button|nullgetSetName()
Gets the full name of the set the card belongs to.
public
getSetName() : string|null
Return values
string|nullgetSubtypes()
Gets the subtypes of the card.
public
getSubtypes() : array<string|int, string>|null
Return values
array<string|int, string>|nullgetSupertypes()
Gets the supertypes of the card.
public
getSupertypes() : array<string|int, string>|null
Return values
array<string|int, string>|nullgetText()
Gets the card's oracle rules text.
public
getText() : string|null
Return values
string|nullgetToughness()
Gets the creature's toughness.
public
getToughness() : string|null
Return values
string|nullgetType()
Gets the type of the card.
public
getType() : string|null
Return values
string|nullgetTypes()
Gets the types of the card.
public
getTypes() : array<string|int, string>|null
Return values
array<string|int, string>|nullgetViewImageButton()
Gets a button to view the image of the card.
public
getViewImageButton(Interaction|null $interaction) : Button|null
Parameters
- $interaction : Interaction|null
Tags
Return values
Button|nullnormalLayoutContainer()
Builds and returns a Container representing the normal layout for a Magic: The Gathering card.
public
normalLayoutContainer(?Interaction $interaction) : Container
Parameters
- $interaction : ?Interaction
Tags
Return values
ContainersetArtist()
Sets the name of the artist who illustrated the card.
public
setArtist(string|null $artist) : self
Parameters
- $artist : string|null
-
Artist name.
Return values
selfsetCmc()
Sets the converted mana cost of the card.
public
setCmc([int $cmc = 0 ]) : $this
Parameters
- $cmc : int = 0
-
Converted mana cost of the card.
Return values
$thissetColorIdentity()
Sets the color identity of the card.
public
setColorIdentity(array<string|int, string>|null $colorIdentity) : $this
Parameters
- $colorIdentity : array<string|int, string>|null
-
Color identity of the card.
Return values
$thissetColors()
Sets the colors of the card.
public
setColors(array<string|int, string>|null $colors) : $this
Parameters
- $colors : array<string|int, string>|null
-
Colors of the card.
Return values
$thissetContains()
Restricts results to cards that have the named field(s) present.
public
setContains(string|null $contains) : self
Parameters
- $contains : string|null
-
Comma-separated field names.
Return values
selfsetFlavor()
Sets the card's flavor text.
public
setFlavor(string|null $flavor) : self
Parameters
- $flavor : string|null
-
Flavor text.
Return values
selfsetGameFormat()
Sets the game format to filter legality against (e.g. "Standard", "Modern").
public
setGameFormat(string|null $gameFormat) : self
Parameters
- $gameFormat : string|null
-
Game format name.
Return values
selfsetId()
Sets the card's unique id (a hash of set code, name and collector number).
public
setId(string|null $id) : self
Parameters
- $id : string|null
-
Card id.
Return values
selfsetLanguage()
Sets the language to match foreign card names against when querying.
public
setLanguage(string|null $language) : self
Parameters
- $language : string|null
-
Language name.
Return values
selfsetLayout()
Sets the layout of the card.
public
setLayout(string|null $layout) : $this
Parameters
- $layout : string|null
-
Layout of the card.
Return values
$thissetLegality()
Sets the legality status to filter by ("Legal", "Banned" or "Restricted").
public
setLegality(string|null $legality) : self
Parameters
- $legality : string|null
-
Legality status.
Return values
selfsetLoyalty()
Sets the planeswalker's starting loyalty.
public
setLoyalty(int|null $loyalty) : self
Parameters
- $loyalty : int|null
-
Starting loyalty.
Return values
selfsetMultiverseid()
Sets the card's Gatherer multiverse id.
public
setMultiverseid(int|null $multiverseid) : self
Parameters
- $multiverseid : int|null
-
Multiverse id.
Return values
selfsetName()
Sets the name of the card.
public
setName(string|null $name) : $this
Parameters
- $name : string|null
-
Name of the card.
Return values
$thissetNumber()
Sets the card's collector number within its set.
public
setNumber(string|null $number) : self
Parameters
- $number : string|null
-
Collector number.
Return values
selfsetOrderBy()
Sets the field to order results by.
public
setOrderBy(string|null $orderBy) : self
Parameters
- $orderBy : string|null
-
Field name.
Return values
selfsetPage()
Sets the results page number to request (1-based pagination).
public
setPage(int|null $page) : self
Parameters
- $page : int|null
-
Page number.
Return values
selfsetPageSize()
Sets the number of results per page.
public
setPageSize(int|null $pageSize) : self
Parameters
- $pageSize : int|null
-
Page size, 1-100.
Tags
Return values
selfsetPower()
Sets the creature's power. A string because it may be non-numeric (e.g. "*").
public
setPower(string|null $power) : self
Parameters
- $power : string|null
-
Power.
Return values
selfsetRandom()
Requests a single random card matching the other filters. Only a truthy value has an effect; `false`/`null` leaves the flag unset.
public
setRandom(bool|null $random) : self
Parameters
- $random : bool|null
-
Whether to return a random card.
Return values
selfsetRarity()
Sets the rarity of the card (e.g. "Common", "Rare", "Mythic Rare").
public
setRarity(string|null $rarity) : self
Parameters
- $rarity : string|null
-
Rarity of the card.
Return values
selfsetSet()
Sets the code of the set the card belongs to.
public
setSet(string|null $set) : self
Parameters
- $set : string|null
-
Set code.
Return values
selfsetSetName()
Sets the full name of the set the card belongs to.
public
setSetName(string|null $setName) : self
Parameters
- $setName : string|null
-
Set name.
Return values
selfsetSubtypes()
Sets the subtypes of the card (e.g. "Human", "Wizard", "Equipment").
public
setSubtypes(array<string|int, string>|null $subtypes) : self
Parameters
- $subtypes : array<string|int, string>|null
-
Subtypes of the card.
Return values
selfsetSupertypes()
Sets the supertypes of the card.
public
setSupertypes(array<string|int, string>|null $supertypes) : $this
Parameters
- $supertypes : array<string|int, string>|null
-
Supertypes of the card.
Return values
$thissetText()
Sets the card's oracle rules text.
public
setText(string|null $text) : self
Parameters
- $text : string|null
-
Rules text.
Return values
selfsetToughness()
Sets the creature's toughness. A string because it may be non-numeric (e.g. "*").
public
setToughness(string|null $toughness) : self
Parameters
- $toughness : string|null
-
Toughness.
Return values
selfsetType()
Sets the type of the card.
public
setType(string|null $type) : $this
Parameters
- $type : string|null
-
Type of the card.
Return values
$thissetTypes()
Sets the types of the card.
public
setTypes(array<string|int, string>|null $types) : self
Parameters
- $types : array<string|int, string>|null
-
Types of the card.
Return values
selftoContainer()
Converts the card to a container with components.
public
toContainer([?Interaction $interaction = null ]) : Container|null
Parameters
- $interaction : ?Interaction = null