Created
September 26, 2018 14:28
-
-
Save adri/c358bafe29d87d9ebdb12e6133828d55 to your computer and use it in GitHub Desktop.
Example PaymentContext for creating a payment object.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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