Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Example PaymentContext for creating a payment object.
<?php
class PaymentContext
{
/**
* @var PaymentId
*/
public $paymentId;
/**
* @var Money
*/
public $amount;
public function create(Factory $factory) : Payment
{
return new Payment(
$this->paymentId ?? PaymentId::create(), // random id
$this->amount ?? new Money(\random_int(10, 9999), new Currency('EUR'));
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment