Skip to content

Extension points

tilttek/deck-builder

The package is at 0.x: its extension points are stable only from its 1.0 release. Until then, a minor version may change them, and its CHANGELOG says how.

PointWhat an application givesWhere
Contract\CardCatalogIts cards; Catalog\InMemoryCardCatalog keeps them in memoryCatalogues and licences
Contract\FormatCatalogIts formats; Catalog\InMemoryFormatCatalog keeps them in memoryFormats and rules
Contract\OwnedCardsA collection; Catalog\OwnedCardList reads one from an arrayBuilding and validating decks
Contract\DeckStoreThe versions of the decks; Store\InMemoryDeckStore keeps them in memoryHistory and copies

Every point is passed to a constructor; DeckValidator and Decks keep no state between two calls.

Implementing a store

  • add() returns false, writing nothing, when the store holds that version of that deck: a unique key on the deck's identifier and the version's number gives it.
  • latest() gives the highest version; versions() lists them from the first to the latest.
  • A row keeps DeckVersion::$deck->toJson(), the version, savedAt in UTC and the note; Deck::fromJson() reads the deck back.