DiscordPHP-MTG Documentation

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
link

Card object reference

since
0.4.0

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
inheritDoc

Methods

getArtist()

Gets the name of the artist who illustrated the card.

public getArtist() : string|null
Return values
string|null

getCmc()

Gets the converted mana cost of the card.

public getCmc() : int
Return values
int

getColorIdentity()

Gets the color identity of the card.

public getColorIdentity() : array<string|int, string>|null
Return values
array<string|int, string>|null

getColors()

Gets the colors of the card.

public getColors() : array<string|int, string>|null
Return values
array<string|int, string>|null

getContains()

Gets the "contains" field filter.

public getContains() : string|null
Return values
string|null

getFlavor()

Gets the card's flavor text.

public getFlavor() : string|null
Return values
string|null

getForeignNamesAttribute()

Gets the foreign names of the card.

public getForeignNamesAttribute() : ExCollectionInterface<string|int, ForeignName>
Tags
since
0.3.0
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
since
0.7.0
Return values
Button|null

getGameFormat()

Gets the game format used to filter legality.

public getGameFormat() : string|null
Return values
string|null

getId()

Gets the card's unique id.

public getId() : string|null
Return values
string|null

getImageEmbedAttribute()

Generates an Embed object for the card's image.

public getImageEmbedAttribute() : Embed|null
Tags
since
0.4.0
Return values
Embed|null

getJsonButton()

Gets a button to view the raw JSON of the card.

public getJsonButton(Interaction|null $interaction) : Button|null
Parameters
$interaction : Interaction|null
Tags
since
0.5.0
Return values
Button|null

getLanguage()

Gets the language used when querying foreign card names.

public getLanguage() : string|null
Return values
string|null

getLayout()

Gets the layout of the card.

public getLayout() : string|null
Return values
string|null

getLegalitiesAttribute()

Gets the legality of the card.

public getLegalitiesAttribute() : ExCollectionInterface<string|int, Legality>
Tags
since
0.3.0
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
since
0.6.0
Return values
Button|null

getLegality()

Gets the legality status used to filter results.

public getLegality() : string|null
Return values
string|null

getLoyalty()

Gets the planeswalker's starting loyalty.

public getLoyalty() : int|null
Return values
int|null

getMultiverseid()

Gets the card's Gatherer multiverse id.

public getMultiverseid() : int|null
Return values
int|null

getName()

Gets the name of the card.

public getName() : string|null
Return values
string|null

getNumber()

Gets the card's collector number within its set.

public getNumber() : string|null
Return values
string|null

getOrderBy()

Gets the field results are ordered by.

public getOrderBy() : string|null
Return values
string|null

getPage()

Gets the results page number.

public getPage() : int|null
Return values
int|null

getPageSize()

Gets the number of results per page.

public getPageSize() : int|null
Return values
int|null

getPower()

Gets the creature's power.

public getPower() : string|null
Return values
string|null

getRandom()

Gets whether a random card was requested.

public getRandom() : bool|null
Return values
bool|null

getRarity()

Gets the rarity of the card.

public getRarity() : string|null
Return values
string|null

getReleaseDateAttribute()

Gets the release date of the card.

public getReleaseDateAttribute() : ?Carbon|null
Tags
since
0.3.0
Return values
?Carbon|null

getRulingsAttribute()

Converts the card to a container with components.

public getRulingsAttribute() : ExCollectionInterface<string|int, Ruling>
Tags
since
0.3.0
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|null

getSet()

Gets the code of the set the card belongs to.

public getSet() : string|null
Return values
string|null

getSetButton()

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
since
0.5.0
Return values
Button|null

getSetName()

Gets the full name of the set the card belongs to.

public getSetName() : string|null
Return values
string|null

getSubtypes()

Gets the subtypes of the card.

public getSubtypes() : array<string|int, string>|null
Return values
array<string|int, string>|null

getSupertypes()

Gets the supertypes of the card.

public getSupertypes() : array<string|int, string>|null
Return values
array<string|int, string>|null

getText()

Gets the card's oracle rules text.

public getText() : string|null
Return values
string|null

getToughness()

Gets the creature's toughness.

public getToughness() : string|null
Return values
string|null

getType()

Gets the type of the card.

public getType() : string|null
Return values
string|null

getTypes()

Gets the types of the card.

public getTypes() : array<string|int, string>|null
Return values
array<string|int, string>|null

getViewImageButton()

Gets a button to view the image of the card.

public getViewImageButton(Interaction|null $interaction) : Button|null
Parameters
$interaction : Interaction|null
Tags
since
0.5.0
Return values
Button|null

normalLayoutContainer()

Builds and returns a Container representing the normal layout for a Magic: The Gathering card.

public normalLayoutContainer(?Interaction $interaction) : Container
Parameters
$interaction : ?Interaction
Tags
since
0.4.0
Return values
Container

setArtist()

Sets the name of the artist who illustrated the card.

public setArtist(string|null $artist) : self
Parameters
$artist : string|null

Artist name.

Return values
self

setCmc()

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
$this

setColorIdentity()

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
$this

setColors()

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
$this

setContains()

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
self

setFlavor()

Sets the card's flavor text.

public setFlavor(string|null $flavor) : self
Parameters
$flavor : string|null

Flavor text.

Return values
self

setGameFormat()

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
self

setId()

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
self

setLanguage()

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
self

setLayout()

Sets the layout of the card.

public setLayout(string|null $layout) : $this
Parameters
$layout : string|null

Layout of the card.

Return values
$this

setLegality()

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
self

setLoyalty()

Sets the planeswalker's starting loyalty.

public setLoyalty(int|null $loyalty) : self
Parameters
$loyalty : int|null

Starting loyalty.

Return values
self

setMultiverseid()

Sets the card's Gatherer multiverse id.

public setMultiverseid(int|null $multiverseid) : self
Parameters
$multiverseid : int|null

Multiverse id.

Return values
self

setName()

Sets the name of the card.

public setName(string|null $name) : $this
Parameters
$name : string|null

Name of the card.

Return values
$this

setNumber()

Sets the card's collector number within its set.

public setNumber(string|null $number) : self
Parameters
$number : string|null

Collector number.

Return values
self

setOrderBy()

Sets the field to order results by.

public setOrderBy(string|null $orderBy) : self
Parameters
$orderBy : string|null

Field name.

Return values
self

setPage()

Sets the results page number to request (1-based pagination).

public setPage(int|null $page) : self
Parameters
$page : int|null

Page number.

Return values
self

setPageSize()

Sets the number of results per page.

public setPageSize(int|null $pageSize) : self
Parameters
$pageSize : int|null

Page size, 1-100.

Tags
throws
InvalidArgumentException

When outside the 1-100 range.

Return values
self

setPower()

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
self

setRandom()

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
self

setRarity()

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
self

setSet()

Sets the code of the set the card belongs to.

public setSet(string|null $set) : self
Parameters
$set : string|null

Set code.

Return values
self

setSetName()

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
self

setSubtypes()

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
self

setSupertypes()

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
$this

setText()

Sets the card's oracle rules text.

public setText(string|null $text) : self
Parameters
$text : string|null

Rules text.

Return values
self

setToughness()

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
self

setType()

Sets the type of the card.

public setType(string|null $type) : $this
Parameters
$type : string|null

Type of the card.

Return values
$this

setTypes()

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
self

toContainer()

Converts the card to a container with components.

public toContainer([?Interaction $interaction = null ]) : Container|null
Parameters
$interaction : ?Interaction = null
Tags
since
0.3.0
Return values
Container|null
On this page

Search results