Read from the package's own PHP files at the commit cd454531c385: its namespaces, classes, interfaces and enums, their public constants, properties and methods with their PHPDoc, and the options its factories take. Nothing of it is run.
ChannelenumThe platforms an order or a reservation comes from.
1 method · 11 cases
ConfigclassA platform's configuration while its factory builds it: the options given, the factory's defaults under them, and the keys that must be filled.
3 methods
MenuInterfaceinterfaceThe menu the platform shows: pushed whole (the platform replaces its own), and an item (or a modifier) out of stock for a while.
2 methods
NotifiableInterfaceinterfaceA webhook the platform calls: its body and headers, checked (signature, secret) and read. InvalidSignatureException when the signature does not hold: the controller answers 401 and does nothing. Notification::$id is the platform's id for the event, to handle each once (they retry).
1 method
OrdersInterfaceinterfaceThe orders a delivery platform sends to the restaurant: read, accepted (within the platform's delay: Capabilities::$acceptanceDelay), denied, marked ready, cancelled. An order arrives by NotifiableInterface (a webhook) or by orders() (polling); $ref is always the platform's id.
6 methods
PlatformFactoryclassThe Omnibus way: a platform's factory fills a Config - its name ("omnifood.factory_name"), the options it cannot do without ("omnifood.required_options") and the defaults of the others - and builds its client from it.
4 methods
PlatformFactoryInterfaceinterfaceBuilds a platform's client from its options (a client id, a secret, a store id...).
2 methods
PlatformInterfaceinterfaceA restaurant platform's client, for one restaurant. It implements the capabilities the platform offers - OrdersInterface, MenuInterface, StoreInterface, ReservationsInterface, NotifiableInterface - and Auth\RefreshableInterface or Auth\OAuthInterface when it holds a token.
3 methods
RegistryclassThe platforms by name, each built once from its factory and options:
13 methods
ReservationsInterfaceinterfaceThe table reservations a booking platform holds for the restaurant.
7 methods
StoreInterfaceinterfaceThe restaurant as the platform shows it: open, paused for a rush, its hours.
4 methods
ValidatorclassA menu against a platform's capabilities, before anything is sent: the references (present, one each), the names and descriptions' lengths, the prices (in the menu's currency, not negative), the VAT rates, the modifier groups' bounds and how deep they nest. Readable violations, by path, for a back office to show.
1 method
OAuthInterfaceinterfaceConnecting the restaurant's account from a back office: the URL to send the owner to, the code exchanged on the way back.
2 methods
RefreshableInterfaceinterfaceA platform whose token dies: the client-credentials token (Uber Eats, Deliveroo, TheFork's Auth0) asked for again before it does. The platform fetches one itself when a call needs it; refresh() is for a site that keeps it (a cache, a database) and hands it back through the options.
2 methods
OmnifoodBundleclassOmnifood in a Symfony application: the platform packages installed (omnifood/ubereats, omnifood/deliveroo, omnifood/justeat, omnifood/thefork, omnifood/zenchef) registered, the restaurant's platforms built from configuration, Omnifood\Registry and Omnifood\Validator autowired, and each platform injectable by its name, as what it does:
2 methods · 2 constants
InvalidConfigExceptionclassA platform misconfigured: a credential missing, an unknown factory.
InvalidMenuExceptionclassThe menu breaks the platform's capabilities: nothing was sent.
1 method · 2 properties
InvalidSignatureExceptionclassA webhook whose signature (or secret) does not hold: answer 401, handle nothing.
1 method · 1 property
NotSupportedExceptionclassThe platform does not do that, or its public documentation does not show how: nothing is guessed, the call is refused.
1 method
OmnifoodExceptioninterfaceEvery exception Omnifood throws.
ProviderExceptionclassThe platform refused, or could not be reached.
1 method · 3 properties
UnauthorizedExceptionclassThe credentials are refused, or lack a scope: the keys must be checked, the account connected again.
RedactionclassWhat a failed call may carry of its credentials, taken out before the failure leaves the package: an HTTP client's exception quotes the URL called (a key in its query, a password in its user part), and every exception's trace keeps the arguments of the calls under it (the request options, headers and query with the key) unless PHP runs with zend.exception_ignore_args.
5 methods · 1 constant
AllergenenumThe fourteen allergens EU Regulation 1169/2011 (Annex II) requires a menu to declare.
1 method · 14 cases
CapabilitiesclassWhat a platform takes and imposes, for a back office to show and the Validator to check a menu against before it is sent. What the platform does not say is null (no limit known).
2 methods · 14 properties
CourierclassWho comes to collect a delivery, when the platform says.
1 method · 5 properties
CustomerclassWho ordered, as much as the platform tells (often a first name and a masked phone).
1 method · 5 properties
DenyReasonenumWhy the restaurant refuses or cancels an order; each platform maps it to its own codes.
9 cases
GuestclassWho the table is booked for.
2 methods · 6 properties
HoursclassOpening hours: for each day of the week (1 Monday ... 7 Sunday) its ranges ["11:30", "14:30"], and dates that differ (a holiday closed, a Sunday open). A day with no range is closed; a range may end after midnight ("19:00", "01:00").
4 methods · 2 properties
LineclassOne line of an order: so many of one item, with its choices.
1 method · 8 properties
ModifierclassA choice on an order's line (a sauce, a size, no onions), itself with its choices where the platform nests them.
1 method · 6 properties
MoneyclassAn amount in a currency's minor units (cents): 1250 EUR is 12,50 €.
7 methods · 2 properties
NotificationclassWhat a platform's webhook said, checked: one event about one order, one reservation or the store. $event is the platform's own name for it; $reference the order's (or reservation's) id there, for order() or reservation() to read it whole when the webhook carries only the id; $order or $reservation when it carries it all.
1 method · 11 properties
NotificationSubjectenumWhat a webhook is about.
6 cases
OrderclassAn order as a platform sent it, the same shape for every platform: what, for whom, how it leaves, how much, when. Amounts are Money (minor units); what the platform does not tell is null. $raw keeps the platform's answer.
2 methods · 20 properties
OrderStatusenumWhere an order stands, the same for every platform; Order::$raw keeps the platform's own word.
1 method · 8 cases
OrderTypeenum3 cases
ReservationclassA table booked, the same shape for every platform. $reference is null for a reservation not yet recorded (createReservation() answers it with one).
2 methods · 15 properties
ReservationStatusenumWhere a reservation stands, the same for every platform; Reservation::$raw keeps the platform's own word.
1 method · 9 cases
SlotclassA time a table can be booked at, and for how many.
1 method · 4 properties
StoreStateenum4 cases
StoreStatusclassThe restaurant as the platform shows it now.
2 methods · 4 properties
TokenclassAn access token and when it dies: a site stores it and asks the platform to refresh it in time.
5 methods · 5 properties
ViolationclassOne thing a platform would refuse: where (categories[0].items[2].name...) and why, readable.
2 methods · 2 properties
Categoryclass1 method · 4 properties
ItemclassA dish or a drink.
1 method · 10 properties
MenuclassA menu as a site holds it, the same for every platform: categories of items, each item with its choices (modifier groups), its price, its VAT rate, its allergens. Each platform's pushMenu() turns it into its own shape; every reference ($ref) is the restaurant's own (a POS's), the one the platform carries back on the orders.
2 methods · 6 properties
ModifierclassOne option of a group; it may open groups of its own (a menu's main course, and its cooking).
1 method · 7 properties
ModifierGroupclassA choice on an item: "Your sauce" (exactly 1), "Extras" (0 to 3).
2 methods · 5 properties
Omnifood
Channel enum
enum Channel Channel.php:6
The platforms an order or a reservation comes from.
case UBEREATS = 'ubereats'case DELIVEROO = 'deliveroo'case JUSTEAT = 'justeat'case THEFORK = 'thefork'case ZENCHEF = 'zenchef'case DOORDASH = 'doordash'case WOLT = 'wolt'case GLOVO = 'glovo'case OPENTABLE = 'opentable'case SEVENROOMS = 'sevenrooms'case DIRECT = 'direct'The restaurant's own site, the phone, the walk-in: no platform.
Channel::label()
public function label(): stringConfig class
final class Config extends ArrayObject Config.php:13
A platform's configuration while its factory builds it: the options given, the factory's defaults under them, and the keys that must be filled.
Config::defaults()
public function defaults(array $defaults): selfSets each key not set yet.
Config::validateNotEmpty()
public function validateNotEmpty(array $keys): voidConfig::get()
public function get(string $key, mixed $default = null): mixedMenuInterface interface
interface MenuInterface extends PlatformInterface MenuInterface.php:11
The menu the platform shows: pushed whole (the platform replaces its own), and an item (or a modifier) out of stock for a while.
MenuInterface::pushMenu()
public function pushMenu(Menu $menu): voidA menu that breaks capabilities() is refused before anything is sent (InvalidMenuException).
MenuInterface::setAvailability()
public function setAvailability(string $itemRef, bool $available, ?\DateTimeImmutable $until = null): void$itemRef is the item's POS reference (Item::$ref); $until null: until said otherwise.
NotifiableInterface interface
interface NotifiableInterface extends PlatformInterface NotifiableInterface.php:13
A webhook the platform calls: its body and headers, checked (signature, secret) and read. InvalidSignatureException when the signature does not hold: the controller answers 401 and does nothing. Notification::$id is the platform's id for the event, to handle each once (they retry).
NotifiableInterface::notify()
public function notify(string $body, array $headers): Notification$headersas the request has them, any case
OrdersInterface interface
interface OrdersInterface extends PlatformInterface OrdersInterface.php:14
The orders a delivery platform sends to the restaurant: read, accepted (within the platform's delay: Capabilities::$acceptanceDelay), denied, marked ready, cancelled. An order arrives by NotifiableInterface (a webhook) or by orders() (polling); $ref is always the platform's id.
OrdersInterface::order()
public function order(string $ref): OrderOrdersInterface::orders()
public function orders(?\DateTimeImmutable $since = null): arrayThe orders placed since then, newest first, where the platform lists them (NotSupportedException where it only pushes them).
OrdersInterface::accept()
public function accept(string $ref, ?\DateTimeImmutable $readyAt = null): voidAccepted; $readyAt is when the kitchen expects it ready, where the platform takes it.
OrdersInterface::deny()
public function deny(string $ref, DenyReason $reason, ?string $note = null): voidOrdersInterface::ready()
public function ready(string $ref): voidReady for the courier, or for the customer who collects it.
OrdersInterface::cancel()
public function cancel(string $ref, DenyReason $reason, ?string $note = null): voidAn order already accepted, cancelled by the restaurant.
PlatformFactory class
abstract class PlatformFactory implements PlatformFactoryInterface PlatformFactory.php:19
The Omnibus way: a platform's factory fills a Config - its name ("omnifood.factory_name"), the options it cannot do without ("omnifood.required_options") and the defaults of the others - and builds its client from it.
Options left empty (null, '': an environment variable not set) are as if not given: the defaults stand. A credential is best not required here but asked for when a call needs it, so that a platform without its keys still answers what needs none (capabilities(), a webhook's signature check).
PlatformFactory::__construct()
public function __construct(protected readonly ?HttpClientInterface $http = null)PlatformFactory::getName()
public function getName(): stringPlatformFactory::create()
public function create(array $options = []): PlatformInterfacePlatformFactory::createConfig()
public function createConfig(array $options = []): ConfigPlatformFactoryInterface interface
interface PlatformFactoryInterface PlatformFactoryInterface.php:6
Builds a platform's client from its options (a client id, a secret, a store id...).
PlatformFactoryInterface::getName()
public function getName(): stringThe name platforms are configured with: "ubereats", "thefork".
..
PlatformFactoryInterface::create()
public function create(array $options = []): PlatformInterfacePlatformInterface interface
interface PlatformInterface PlatformInterface.php:15
A restaurant platform's client, for one restaurant. It implements the capabilities the platform offers - OrdersInterface, MenuInterface, StoreInterface, ReservationsInterface, NotifiableInterface - and Auth\RefreshableInterface or Auth\OAuthInterface when it holds a token.
What the platform offers but its public documentation does not show throws Exception\NotSupportedException.
PlatformInterface::getName()
public function getName(): stringThe name it is configured as: "ubereats", "thefork".
..
PlatformInterface::getChannel()
public function getChannel(): ChannelPlatformInterface::capabilities()
public function capabilities(): CapabilitiesWhat the platform takes and imposes, for a back office and the Validator.
Registry class
final class Registry Registry.php:14
The platforms by name, each built once from its factory and options:
new Registry([new UberEatsPlatformFactory($http)], [ 'ubereats' => ['factory' => 'ubereats', 'options' => ['client_id' => '...', 'client_secret' => '...', 'store_id' => '...']], ]);
Registry::__construct()
public function __construct(iterable $factories, readonly array $config)Registry::get()
public function get(string $name): PlatformInterfaceRegistry::create()
public function create(string $name, array $overrides = []): PlatformInterfaceA platform built afresh, its configured options with $overrides over them - keys typed in a back office, a token kept in a database. Not kept: get() still gives the configured one.
Registry::has()
public function has(string $name): boolRegistry::options()
public function options(string $name): arrayRegistry::names()
public function names(): arrayRegistry::all()
public function all(): arrayRegistry::orders()
public function orders(): arrayRegistry::menus()
public function menus(): arrayRegistry::stores()
public function stores(): arrayRegistry::reservations()
public function reservations(): arrayRegistry::notifiables()
public function notifiables(): arrayRegistry::factories()
public function factories(): array- Returns
the factories installed
ReservationsInterface interface
interface ReservationsInterface extends PlatformInterface ReservationsInterface.php:15
The table reservations a booking platform holds for the restaurant.
The methods that write are named after the reservation - createReservation(), updateReservation(), cancelReservation() - so that one platform may take both orders and reservations: OrdersInterface::cancel() is an order's.
ReservationsInterface::reservations()
public function reservations(\DateTimeImmutable $from, \DateTimeImmutable $to): arrayThe reservations from $from to $to (their date), oldest first.
ReservationsInterface::reservation()
public function reservation(string $ref): ReservationReservationsInterface::createReservation()
public function createReservation(Reservation $reservation): ReservationA reservation taken by the restaurant (the phone, the site), recorded on the platform: answered with its reference there.
ReservationsInterface::updateReservation()
public function updateReservation(Reservation $reservation): Reservation$reservation->reference says which; its date, covers, guest and notes replace the platform's.
ReservationsInterface::cancelReservation()
public function cancelReservation(string $ref, ?string $reason = null): voidReservationsInterface::setStatus()
public function setStatus(string $ref, ReservationStatus $status): voidArrived, seated, left, no-show...: the service as it goes.
ReservationsInterface::pushAvailability()
public function pushAvailability(array $slots): voidThe tables free, slot by slot, for the platform to sell.
StoreInterface interface
interface StoreInterface extends PlatformInterface StoreInterface.php:9
The restaurant as the platform shows it: open, paused for a rush, its hours.
StoreInterface::status()
public function status(): StoreStatusStoreInterface::pause()
public function pause(?\DateTimeImmutable $until = null, ?string $reason = null): voidNo more orders until $until (null: until resume()).
StoreInterface::resume()
public function resume(): voidStoreInterface::setHours()
public function setHours(Hours $hours): voidValidator class
final class Validator Validator.php:22
A menu against a platform's capabilities, before anything is sent: the references (present, one each), the names and descriptions' lengths, the prices (in the menu's currency, not negative), the VAT rates, the modifier groups' bounds and how deep they nest. Readable violations, by path, for a back office to show.
What a platform ignores is not a violation (a photo where it takes none): only what it would refuse.
Validator::validate()
public function validate(Menu $menu, Capabilities $c): arrayOmnifood\Auth
OAuthInterface interface
interface OAuthInterface OAuthInterface.php:8
Connecting the restaurant's account from a back office: the URL to send the owner to, the code exchanged on the way back.
OAuthInterface::authorizationUrl()
public function authorizationUrl(string $redirectUri, string $state, array $scopes = []): stringOAuthInterface::exchange()
public function exchange(string $code, string $redirectUri): TokenRefreshableInterface interface
interface RefreshableInterface RefreshableInterface.php:13
A platform whose token dies: the client-credentials token (Uber Eats, Deliveroo, TheFork's Auth0) asked for again before it does. The platform fetches one itself when a call needs it; refresh() is for a site that keeps it (a cache, a database) and hands it back through the options.
RefreshableInterface::token()
public function token(): ?TokenRefreshableInterface::refresh()
public function refresh(): TokenOmnifood\Bridge\Symfony
OmnifoodBundle class
final class OmnifoodBundle extends AbstractBundle OmnifoodBundle.php:49
Omnifood in a Symfony application: the platform packages installed (omnifood/ubereats, omnifood/deliveroo, omnifood/justeat, omnifood/thefork, omnifood/zenchef) registered, the restaurant's platforms built from configuration, Omnifood\Registry and Omnifood\Validator autowired, and each platform injectable by its name, as what it does:
omnifood: platforms: ubereats: { factory: ubereats, options: { client_id: '%env(default::UBEREATS_CLIENT_ID)%', client_secret: '%env(default::UBEREATS_CLIENT_SECRET)%', store_id: '%env(default::UBEREATS_STORE_ID)%' } } thefork: { factory: thefork, options: { client_id: '%env(default::THEFORK_CLIENT_ID)%', client_secret: '%env(default::THEFORK_CLIENT_SECRET)%', restaurant_id: '%env(default::THEFORK_RESTAURANT_ID)%' } }
public function __construct(OrdersInterface $ubereats, ReservationsInterface $thefork) }Nothing is built, nor checked, when the container compiles: a platform is built the first time it is asked for, and a credential left empty only shows when a call needs it (InvalidConfigException). So a site with no keys yet still boots; Registry::has() says a platform is declared.
An application's own factories (a PlatformFactoryInterface) are registered too, autoconfigured.
const FACTORIES = [UberEatsPlatformFactory::class, DeliverooPlatformFactory::class, JustEatPlatformFactory::class, TheForkPlatformFactory::class, ZenchefPlatformFactory::class]The platform packages this bundle knows, registered when installed.
const CAPABILITIES = [PlatformInterface::class, OrdersInterface::class, MenuInterface::class, StoreInterface::class, ReservationsInterface::class, NotifiableInterface::class]What a platform may be injected as, by its name.
OmnifoodBundle::configure()
public function configure(DefinitionConfigurator $definition): voidOmnifoodBundle::loadExtension()
public function loadExtension(array $config, ContainerConfigurator $container, ContainerBuilder $builder): voidOmnifood\Exception
InvalidConfigException class
final class InvalidConfigException extends LogicException implements OmnifoodException InvalidConfigException.php:6
A platform misconfigured: a credential missing, an unknown factory.
InvalidMenuException class
final class InvalidMenuException extends InvalidArgumentException implements OmnifoodException InvalidMenuException.php:8
The menu breaks the platform's capabilities: nothing was sent.
InvalidMenuException::__construct()
public function __construct(public readonly string $platform, public readonly array $violations)InvalidSignatureException class
final class InvalidSignatureException extends RuntimeException implements OmnifoodException InvalidSignatureException.php:6
A webhook whose signature (or secret) does not hold: answer 401, handle nothing.
public readonly string $platform
InvalidSignatureException::__construct()
public function __construct(public readonly string $platform, string $message)NotSupportedException class
final class NotSupportedException extends LogicException implements OmnifoodException NotSupportedException.php:9
The platform does not do that, or its public documentation does not show how: nothing is guessed, the call is refused.
NotSupportedException::operation()
public static function operation(string $platform, string $operation): selfOmnifoodException interface
interface OmnifoodException extends Throwable OmnifoodException.php:6
Every exception Omnifood throws.
ProviderException class
class ProviderException extends RuntimeException implements OmnifoodException ProviderException.php:6
The platform refused, or could not be reached.
public readonly string $platformpublic readonly ?int $statuspublic readonly ?string $providerCodeThe platform's own error code, when it gave one
ProviderException::__construct()
public function __construct(public readonly string $platform, string $message, public readonly ?int $status = null, public readonly ?string $providerCode = null, ?\Throwable $previous = null)UnauthorizedException class
final class UnauthorizedException extends ProviderException UnauthorizedException.php:6
The credentials are refused, or lack a scope: the keys must be checked, the account connected again.
Omnifood\Http
Redaction class
final class Redaction Redaction.php:22
What a failed call may carry of its credentials, taken out before the failure leaves the package: an HTTP client's exception quotes the URL called (a key in its query, a password in its user part), and every exception's trace keeps the arguments of the calls under it (the request options, headers and query with the key) unless PHP runs with zend.exception_ignore_args.
copy() gives the previous exception to wrap instead of the client's own: the same class and code, its message with the key's parameters, the user part and every secret value replaced by ***, its trace without arguments, its own previous copied the same way. Properties of the client's class beyond those of \Exception are not copied (a Symfony HttpException's response, a PSR-18 exception's request: their URL holds the key). withoutArguments() takes the arguments out of the trace of the exception thrown in its place.
const MASK = '***'
Redaction::secrets()
public static function secrets(string $url, array $options = []): arrayThe secrets a request carries: the values of its query parameters, headers and body fields named as credentials (key, token, secret, password, signature, auth...), a bearer token, a basic password, the URL's user part.
$optionsthe HTTP client's options
Redaction::sensitive()
public static function sensitive(string $name): boolWhether a parameter, header or field of this name holds a credential.
Redaction::text()
public static function text(string $text, array $secrets = []): stringA text without credentials: in every address, the user part and the parameters named as credentials masked (api_key=***); then every secret given, raw or URL-encoded, masked wherever it stands.
Redaction::copy()
public static function copy(\Throwable $failure, array $secrets = []): \ThrowableA copy of a failure to wrap in its place: its class, code, file and line, its message through text(), its trace without arguments, its previous copied the same way.
Redaction::withoutArguments()
public static function withoutArguments(\Throwable $failure): \ThrowableThe failure given, the arguments out of its trace (and out of its previous ones'), as zend.exception_ignore_args would have left it.
Omnifood\Model
Allergen enum
enum Allergen Allergen.php:6
The fourteen allergens EU Regulation 1169/2011 (Annex II) requires a menu to declare.
case GLUTEN = 'gluten'case CRUSTACEANS = 'crustaceans'case EGGS = 'eggs'case FISH = 'fish'case PEANUTS = 'peanuts'case SOYBEANS = 'soybeans'case MILK = 'milk'case NUTS = 'nuts'case CELERY = 'celery'case MUSTARD = 'mustard'case SESAME = 'sesame'case SULPHITES = 'sulphites'case LUPIN = 'lupin'case MOLLUSCS = 'molluscs'
Allergen::label()
public function label(): stringCapabilities class
final readonly class Capabilities Capabilities.php:10
What a platform takes and imposes, for a back office to show and the Validator to check a menu against before it is sent. What the platform does not say is null (no limit known).
public array $orderTypespublic ?int $acceptanceDelaySeconds the restaurant has to accept a new order before the platform cancels it (Uber Eats: 11.5 minutes)
public bool $readyAtWhether accept() takes when the order will be ready
public int $modifierDepthHow deep modifiers nest: 0 none, 1 an item's groups, 2 a modifier's own groups.
..
public bool $allergensWhether the menu carries the EU-14 allergens
public bool $photospublic bool $vatRatesWhether each item carries its VAT rate
public ?int $nameMaxLengthpublic ?int $descriptionMaxLengthpublic bool $pauseUntilWhether pause() takes an end
public bool $depositsWhether a reservation may carry a deposit or a card guarantee
public bool $availabilityPushWhether the restaurant can push its free tables (pushAvailability())
public array $currenciesISO 4217; [] any
public bool $modifiersAreItemsWhether a modifier must be a menu item of its own on the platform (Uber Eats: every option is an item)
Capabilities::__construct()
public function __construct(public array $orderTypes = [], public ?int $acceptanceDelay = null, public bool $readyAt = false, public int $modifierDepth = 1, public bool $allergens = false, public bool $photos = false, public bool $vatRates = false, public ?int $nameMaxLength = null, public ?int $descriptionMaxLength = null, public bool $pauseUntil = false, public bool $deposits = false, public bool $availabilityPush = false, public array $currencies = [], public bool $modifiersAreItems = false)$currenciesISO 4217; [] any
Capabilities::takes()
public function takes(OrderType $type): boolCourier class
final readonly class Courier Courier.php:6
Who comes to collect a delivery, when the platform says.
public ?string $namepublic ?string $phonepublic ?string $statusThe platform's word: "ARRIVED_AT_PICKUP", "rider_assigned".
..
public ?\DateTimeImmutable $arrivesAtpublic ?string $vehicle
Courier::__construct()
public function __construct(public ?string $name = null, public ?string $phone = null, public ?string $status = null, public ?\DateTimeImmutable $arrivesAt = null, public ?string $vehicle = null)Customer class
final readonly class Customer Customer.php:6
Who ordered, as much as the platform tells (often a first name and a masked phone).
public ?string $namepublic ?string $phonepublic ?string $phoneCodeAn extension or code to dial after the platform's masked number
public ?string $emailpublic ?string $addressThe delivery address, one line, when the restaurant delivers itself
Customer::__construct()
public function __construct(public ?string $name = null, public ?string $phone = null, public ?string $phoneCode = null, public ?string $email = null, public ?string $address = null)DenyReason enum
enum DenyReason DenyReason.php:6
Why the restaurant refuses or cancels an order; each platform maps it to its own codes.
case CLOSED = 'closed'case TOO_BUSY = 'too_busy'case CUSTOMER_REQUEST = 'customer_request'case ADDRESS = 'address'case PRICING = 'pricing'case SPECIAL_INSTRUCTIONS = 'special_instructions'case TECHNICAL = 'technical'case OTHER = 'other'
Guest class
final readonly class Guest Guest.php:6
Who the table is booked for.
public ?string $firstNamepublic ?string $lastNamepublic ?string $emailpublic ?string $phonepublic ?string $locale"fr", "en_GB".
..
public ?string $idThe platform's id for the guest
Guest::__construct()
public function __construct(public ?string $firstName = null, public ?string $lastName = null, public ?string $email = null, public ?string $phone = null, public ?string $locale = null, public ?string $id = null)Guest::name()
public function name(): stringHours class
final readonly class Hours Hours.php:11
Opening hours: for each day of the week (1 Monday ... 7 Sunday) its ranges ["11:30", "14:30"], and dates that differ (a holiday closed, a Sunday open). A day with no range is closed; a range may end after midnight ("19:00", "01:00").
public array $weekpublic array $exceptions
Hours::__construct()
public function __construct(array $week, array $exceptions = [])Hours::day()
public function day(int $day): array- Returns
the ranges of that day of the week, [] when closed
Hours::on()
public function on(\DateTimeInterface $date): array- Returns
that date's ranges: its exception, or its day of the week's
Hours::isOpenAt()
public function isOpenAt(\DateTimeImmutable $at): boolWhether $at falls in one of its date's ranges (a range past midnight counted on the day it starts).
Line class
final readonly class Line Line.php:6
One line of an order: so many of one item, with its choices.
public string $namepublic int $quantitypublic ?Money $unitPricepublic ?Money $totalThe line's total, modifiers included, as the platform counts it
public ?string $posRefThe restaurant's reference (Menu\Item::$ref), when the platform carries it back
public ?string $platformRefThe platform's own id for the item
public array $modifierspublic ?string $note"Well done", "no onions": the customer's words for this line
Line::__construct()
public function __construct(public string $name, public int $quantity, public ?Money $unitPrice = null, public ?Money $total = null, public ?string $posRef = null, public ?string $platformRef = null, public array $modifiers = [], public ?string $note = null)Modifier class
final readonly class Modifier Modifier.php:6
A choice on an order's line (a sauce, a size, no onions), itself with its choices where the platform nests them.
public string $namepublic int $quantitypublic ?Money $priceThe price of one, on top of the item's
public ?string $posRefThe restaurant's reference for it (Menu\Modifier::$ref), when the platform carries it back
public ?string $groupThe modifier group it was chosen in, by name
public array $modifiers
Modifier::__construct()
public function __construct(public string $name, public int $quantity = 1, public ?Money $price = null, public ?string $posRef = null, public ?string $group = null, public array $modifiers = [])Money class
final readonly class Money Money.php:6
An amount in a currency's minor units (cents): 1250 EUR is 12,50 €.
public string $currencypublic int $amount
Money::__construct()
public function __construct(public int $amount, string $currency)Money::of()
public static function of(int $amount, string $currency): selfMoney::equals()
public function equals(self $other): boolMoney::decimal()
public function decimal(): stringIn major units, as a provider's decimal API expects ("12.50"); yen and the like have none.
Money::fromDecimal()
public static function fromDecimal(string|float $decimal, string $currency): selfFrom a provider's decimal ("12.50"), to minor units.
Money::minorDigits()
public static function minorDigits(string $currency): intHow many minor digits a currency has: 2 for most, 0 for JPY, KRW..., 3 for BHD, KWD.
..
Money::__toString()
public function __toString(): stringNotification class
final readonly class Notification Notification.php:14
What a platform's webhook said, checked: one event about one order, one reservation or the store. $event is the platform's own name for it; $reference the order's (or reservation's) id there, for order() or reservation() to read it whole when the webhook carries only the id; $order or $reservation when it carries it all.
public Channel $channelpublic string $eventThe platform's event type: "orders.notification", "order.new".
..
public NotificationSubject $subjectpublic ?string $referencepublic ?string $idThe platform's id for the event, to handle it once: platforms retry
public ?Order $orderpublic ?Reservation $reservationpublic OrderStatus|ReservationStatus|null $statusThe status it announces, when it announces one
public ?\DateTimeImmutable $occurredAtpublic ?string $storeThe store (restaurant) id it concerns
public array $raw
Notification::__construct()
public function __construct(public Channel $channel, public string $event, public NotificationSubject $subject, public ?string $reference = null, public ?string $id = null, public ?Order $order = null, public ?Reservation $reservation = null, public OrderStatus|ReservationStatus|null $status = null, public ?\DateTimeImmutable $occurredAt = null, public ?string $store = null, public array $raw = [])NotificationSubject enum
enum NotificationSubject NotificationSubject.php:6
What a webhook is about.
case ORDER = 'order'case COURIER = 'courier'The courier of an order: assigned, arrived, gone
case RESERVATION = 'reservation'case STORE = 'store'case OTHER = 'other'
Order class
final readonly class Order Order.php:14
An order as a platform sent it, the same shape for every platform: what, for whom, how it leaves, how much, when. Amounts are Money (minor units); what the platform does not tell is null. $raw keeps the platform's answer.
public Channel $channelpublic string $referenceThe platform's id: what every call on the order takes
public ?string $displayIdThe short number the courier and the customer say ("A1B2C", "#42")
public OrderType $typepublic OrderStatus $statuspublic array $linespublic ?Customer $customerpublic ?Money $totalWhat the customer paid
public ?Money $subtotalThe items, before fees and discounts
public ?Money $discountDiscounts and promotions, as a positive amount
public ?Money $feesDelivery, service, bag fees
public ?Money $taxpublic ?\DateTimeImmutable $placedAtpublic ?\DateTimeImmutable $pickupAtWhen it should be ready (collected by the courier or the customer)
public ?\DateTimeImmutable $deliverAtWhen it should reach the customer, for a delivery
public ?Courier $courierpublic ?string $noteThe customer's note for the whole order (allergies included where the platform has no field of its own)
public ?string $storeThe store (restaurant) id on the platform
public ?bool $cutleryCutlery asked for, when the platform says
public array $raw
Order::__construct()
public function __construct(public Channel $channel, public string $reference, public ?string $displayId, public OrderType $type, public OrderStatus $status, public array $lines = [], public ?Customer $customer = null, public ?Money $total = null, public ?Money $subtotal = null, public ?Money $discount = null, public ?Money $fees = null, public ?Money $tax = null, public ?\DateTimeImmutable $placedAt = null, public ?\DateTimeImmutable $pickupAt = null, public ?\DateTimeImmutable $deliverAt = null, public ?Courier $courier = null, public ?string $note = null, public ?string $store = null, public ?bool $cutlery = null, public array $raw = [])Order::count()
public function count(): intHow many items, modifiers not counted.
OrderStatus enum
enum OrderStatus OrderStatus.php:6
Where an order stands, the same for every platform; Order::$raw keeps the platform's own word.
case NEW = 'new'Sent to the restaurant, waiting for its answer
case ACCEPTED = 'accepted'case READY = 'ready'Ready for the courier or the customer
case PICKED_UP = 'picked_up'Collected: on its way, or in the customer's hands
case DELIVERED = 'delivered'case DENIED = 'denied'Refused by the restaurant before it was accepted
case CANCELLED = 'cancelled'case UNKNOWN = 'unknown'The platform's word for it is not one of these
OrderStatus::isFinal()
public function isFinal(): boolOrderType enum
enum OrderType OrderType.php:5
case DELIVERY = 'delivery'Taken to the customer, by the platform's courier or the restaurant's own
case PICKUP = 'pickup'Collected at the counter by the customer
case DINE_IN = 'dine_in'Eaten at the restaurant
Reservation class
final readonly class Reservation Reservation.php:11
A table booked, the same shape for every platform. $reference is null for a reservation not yet recorded (createReservation() answers it with one).
public \DateTimeImmutable $dateWhen the guests come: the date and the time, in the restaurant's time zone
public int $coverspublic Guest $guestpublic ReservationStatus $statuspublic ?string $referencepublic ?Channel $channelpublic ?string $notesThe guest's request ("a high chair", "a birthday")
public ?string $allergiespublic ?string $tableThe table asked for or given, by its name or number
public ?int $durationMinutes the table is held
public ?Money $depositA deposit or prepayment taken, or a card imprint's guarantee
public ?string $sourceWhere it came from inside the platform: "widget", "marketplace", "phone".
..
public ?\DateTimeImmutable $createdAtpublic ?string $restaurantThe restaurant's id on the platform
public array $raw
Reservation::__construct()
public function __construct(public \DateTimeImmutable $date, public int $covers, public Guest $guest, public ReservationStatus $status = ReservationStatus::CONFIRMED, public ?string $reference = null, public ?Channel $channel = null, public ?string $notes = null, public ?string $allergies = null, public ?string $table = null, public ?int $duration = null, public ?Money $deposit = null, public ?string $source = null, public ?\DateTimeImmutable $createdAt = null, public ?string $restaurant = null, public array $raw = [])Reservation::with()
public function with(mixed ...$changes): selfThe same reservation with its fields replaced: a reference given back, a new time.
ReservationStatus enum
enum ReservationStatus ReservationStatus.php:6
Where a reservation stands, the same for every platform; Reservation::$raw keeps the platform's own word.
case REQUESTED = 'requested'Asked for, waiting for the restaurant (or a deposit)
case CONFIRMED = 'confirmed'case ARRIVED = 'arrived'At the door, not seated yet
case SEATED = 'seated'case FINISHED = 'finished'Paid and gone
case NO_SHOW = 'no_show'case CANCELLED = 'cancelled'case REFUSED = 'refused'Refused by the restaurant
case UNKNOWN = 'unknown'
ReservationStatus::isFinal()
public function isFinal(): boolSlot class
final readonly class Slot Slot.php:6
A time a table can be booked at, and for how many.
public \DateTimeImmutable $startpublic int $coversThe covers still bookable at that time; 0 is full
public ?\DateTimeImmutable $endpublic ?string $areaThe room or terrace it is in, when the platform sells them apart
Slot::__construct()
public function __construct(public \DateTimeImmutable $start, public int $covers, public ?\DateTimeImmutable $end = null, public ?string $area = null)StoreState enum
enum StoreState StoreState.php:5
case OPEN = 'open'Taking orders
case PAUSED = 'paused'Within its hours, but taking none for a while (a rush, a shortage)
case CLOSED = 'closed'Outside its hours
case UNKNOWN = 'unknown'
StoreStatus class
final readonly class StoreStatus StoreStatus.php:6
The restaurant as the platform shows it now.
public StoreState $statepublic ?\DateTimeImmutable $untilWhen a pause ends, when the platform says
public ?string $reasonpublic array $raw
StoreStatus::__construct()
public function __construct(public StoreState $state, public ?\DateTimeImmutable $until = null, public ?string $reason = null, public array $raw = [])StoreStatus::isOpen()
public function isOpen(): boolToken class
final class Token Token.php:6
An access token and when it dies: a site stores it and asks the platform to refresh it in time.
public readonly string $accessTokenpublic readonly ?\DateTimeImmutable $expiresAtpublic readonly ?string $refreshTokenpublic readonly array $scopespublic readonly ?string $accountId
Token::__construct()
public function __construct(public readonly string $accessToken, public readonly ?\DateTimeImmutable $expiresAt = null, public readonly ?string $refreshToken = null, public readonly array $scopes = [], public readonly ?string $accountId = null)Token::isExpired()
public function isExpired(?\DateTimeImmutable $now = null): boolToken::isExpiring()
public function isExpiring(int $days = 10, ?\DateTimeImmutable $now = null): boolTrue within $days of the end: time to refresh.
Token::toArray()
public function toArray(): arrayToken::fromArray()
public static function fromArray(array $data): selfViolation class
final readonly class Violation Violation.php:6
One thing a platform would refuse: where (categories[0].items[2].name...) and why, readable.
public string $pathpublic string $message
Violation::__construct()
public function __construct(public string $path, public string $message)Violation::__toString()
public function __toString(): stringOmnifood\Model\Menu
Category class
final readonly class Category Category.php:5
Category::__construct()
public function __construct(public string $ref, public string $name, public array $items, public ?string $description = null)Item class
final readonly class Item Item.php:9
A dish or a drink.
The restaurant's reference: the one setAvailability() and the orders take
In percent: 10.0, 5.5, 20.0
A public URL the platform fetches
"vegetarian", "vegan", "spicy", "halal"...
Item::__construct()
public function __construct(public string $ref, public string $name, public Money $price, public ?string $description = null, public ?float $vatRate = null, public array $allergens = [], public ?string $photo = null, public array $modifierGroups = [], public bool $available = true, public array $labels = [])$labels"vegetarian", "vegan", "spicy", "halal"...
Menu class
final readonly class Menu Menu.php:14
A menu as a site holds it, the same for every platform: categories of items, each item with its choices (modifier groups), its price, its VAT rate, its allergens. Each platform's pushMenu() turns it into its own shape; every reference ($ref) is the restaurant's own (a POS's), the one the platform carries back on the orders.
When it is served; null: whenever the store is open
Menu::__construct()
public function __construct(public string $name, public array $categories, public string $currency = 'EUR', public ?Hours $hours = null, public ?string $ref = null, public ?string $description = null)Menu::items()
public function items(): array- Returns
every item, in the order of the categories
Modifier class
final readonly class Modifier Modifier.php:9
One option of a group; it may open groups of its own (a menu's main course, and its cooking).
On top of the item's; null or zero: free
Modifier::__construct()
public function __construct(public string $ref, public string $name, public ?Money $price = null, public array $allergens = [], public bool $available = true, public array $modifierGroups = [], public ?float $vatRate = null)ModifierGroup class
final readonly class ModifierGroup ModifierGroup.php:6
A choice on an item: "Your sauce" (exactly 1), "Extras" (0 to 3).
null: as many as there are
ModifierGroup::__construct()
public function __construct(public string $ref, public string $name, public array $modifiers, public int $min = 0, public ?int $max = null)ModifierGroup::isRequired()
public function isRequired(): bool