DiscordPHP-MTG Documentation

PriceBuilder
in package

FinalYes

Turns MTGJSON's `AllPricesToday.json` into the small SQLite build {@see PriceDatabase} reads.

MTGJSON publishes a day of prices as one 53 MB JSON document; decoding it takes close to a gigabyte, which is no job for a long-running bot. The prices GitHub Actions workflow runs this once a day instead (build-prices.php) and publishes the result as a release asset.

The build has one row per card printing in prices, keyed by uuid, with one REAL column per medium.provider.kind.finish that has any price (paper.tcgplayer.retail.normal, paper.cardkingdom.buylist.foil, mtgo.cardhoarder.retail.normal, …). priceColumns says what each column is and its currency, so a provider MTGJSON adds later needs no code change. meta carries MTGJSON's build date and version.

Deliberately free of dependencies, so the workflow can run it without a Composer install.

Tags
link

Price Formats model

since
1.1.0

Table of Contents

Constants

KINDS  : array<string|int, string> = ['retail', 'buylist']
Which price lists to keep, in column order.

Methods

build()  : int
Writes the price build.
flatten()  : array{0: array, 1: array>}
Flattens MTGJSON's price data to one row of latest prices per card.

Constants

KINDS

Which price lists to keep, in column order.

public array<string|int, string> KINDS = ['retail', 'buylist']

Methods

build()

Writes the price build.

public static build(array<string|int, mixed> $data, array<string|int, mixed> $meta, string $path) : int
Parameters
$data : array<string|int, mixed>

MTGJSON's price data.

$meta : array<string|int, mixed>

MTGJSON's meta (date, version).

$path : string

The SQLite file to create; an existing one is replaced.

Return values
int —

The number of cards with a price.

flatten()

Flattens MTGJSON's price data to one row of latest prices per card.

public static flatten(array<string|int, mixed> $data) : array{0: array, 1: array>}
Parameters
$data : array<string|int, mixed>

AllPricesToday.json's data: uuid → medium → provider → {currency, retail, buylist}.

Return values
array{0: array, 1: array>} —

The columns, sorted, and the rows by uuid.

On this page

Search results