Created
March 3, 2018 09:27
-
-
Save webdevilopers/3a38ea221df451b6f28ec2080b617958 to your computer and use it in GitHub Desktop.
Making domain services testable
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 | |
namespace Sps\Intranet\Domain\Model\Offer; | |
use Sps\Intranet\Domain\Model\Partner\PartnerId; | |
use Sps\Intranet\Infrastructure\Projection\Mongo\OfferReadModelFinder; | |
/** | |
* Class OfferNumberGenerator | |
* @package Sps\Intranet\Domain\Model\Offer | |
*/ | |
class OfferNumberGenerator | |
{ | |
/** @var OfferReadModelFinder $offers */ | |
private $offers; | |
/** | |
* OfferNumberGenerator constructor. | |
* @param OfferReadModelFinder $offers | |
*/ | |
public function __construct(OfferReadModelFinder $offers) | |
{ | |
$this->offers = $offers; | |
} | |
/** | |
* @param PartnerId $partnerId | |
* @return OfferNumber | |
*/ | |
function generate(PartnerId $partnerId) | |
{ | |
$currentOfferNumber = $this->offers->currentOfferNumber($partnerId); | |
return null !== $currentOfferNumber ? $currentOfferNumber->next() : OfferNumber::generate(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Came from: