-
-
Save adelf/a3c8a88879c1a200122ca1dd5030ba9d to your computer and use it in GitHub Desktop.
Domain
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 | |
final class Proposal | |
{ | |
/** @var Freelancer */ | |
private $freelancer; | |
/** @var Money */ | |
private $hourRate; | |
/** @var string */ | |
private $coverLetterMessage; | |
public function __construct(Freelancer $freelancer, Money $hourRate, string $coverLetterMessage) | |
{ | |
$this->freelancer = $freelancer; | |
$this->hourRate = $hourRate; | |
$this->coverLetterMessage = $coverLetterMessage; | |
} | |
} | |
final class Freelancer | |
{ | |
/** @var Email */ | |
private $email; | |
/** @var Money */ | |
private $hourRate; | |
public function __construct(Email $email, Money $hourRate) | |
{ | |
$this->email = $email; | |
$this->hourRate = $hourRate; | |
} | |
public function makeProposal(string $coverLetterMessage): Proposal | |
{ | |
return new Proposal($this, $this->hourRate, $coverLetterMessage); | |
} | |
} | |
final class Job | |
{ | |
/** @var Customer */ | |
private $customer; | |
/** @var JobDescription */ | |
private $description; | |
/** @var Proposal[] */ | |
private $proposals; | |
/** @var int */ | |
private $proposalsLimit; | |
private function __construct(Customer $customer, JobDescription $description) | |
{ | |
$this->customer = $customer; | |
$this->description = $description; | |
$this->proposals = []; | |
$this->proposalsLimit = 0; | |
} | |
public static function post(Customer $customer, JobDescription $description): Job | |
{ | |
return new Job($customer, $description); | |
} | |
public function newProposal(Freelancer $freelancer, string $coverLetterMessage) | |
{ | |
$this->proposals[] = $freelancer->makeProposal($coverLetterMessage); | |
} | |
} |
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 | |
final class Proposal | |
{ | |
/** @var Freelancer */ | |
private $freelancer; | |
/** @var Money */ | |
private $hourRate; | |
/** @var string */ | |
private $coverLetterMessage; | |
public function __construct(Freelancer $freelancer, Money $hourRate, string $coverLetterMessage) | |
{ | |
$this->freelancer = $freelancer; | |
$this->hourRate = $hourRate; | |
$this->coverLetterMessage = $coverLetterMessage; | |
} | |
} | |
final class Freelancer | |
{ | |
/** @var Email */ | |
private $email; | |
/** @var Money */ | |
private $hourRate; | |
public function __construct(Email $email, Money $hourRate) | |
{ | |
$this->email = $email; | |
$this->hourRate = $hourRate; | |
} | |
public function apply(Job $job, string $coverLetterMessage) | |
{ | |
$job->newProposal(new Proposal($this, $this->hourRate, $coverLetterMessage)); | |
} | |
} | |
final class Job | |
{ | |
/** @var Customer */ | |
private $customer; | |
/** @var JobDescription */ | |
private $description; | |
/** @var Proposal[] */ | |
private $proposals; | |
/** @var int */ | |
private $proposalsLimit; | |
private function __construct(Customer $customer, JobDescription $description) | |
{ | |
$this->customer = $customer; | |
$this->description = $description; | |
$this->proposals = []; | |
$this->proposalsLimit = 0; | |
} | |
public static function post(Customer $customer, JobDescription $description): Job | |
{ | |
return new Job($customer, $description); | |
} | |
public function addProposal(Proposal $proposal) | |
{ | |
$this->proposals[] = $proposal; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment