Skip to content

Instantly share code, notes, and snippets.

@Tocacar
Created April 11, 2013 14:53
Show Gist options
  • Select an option

  • Save Tocacar/5364044 to your computer and use it in GitHub Desktop.

Select an option

Save Tocacar/5364044 to your computer and use it in GitHub Desktop.
class CostCentreManager
{
protected $grant;
protected $notice;
protected $validators = array();
public function __construct(
Validator $costCentreNotRequired,
Validator $hasCostCentre,
Validator $hasNoCostCentre,
Validator $hasFunder,
Validator $hasType,
Validator $hasPrimaryInvestigator
)
{
foreach (func_get_args() as $validator) {
$this->addValidator($validator);
}
}
public function addValidator(Validator $validator)
{
$this->validators[] = $validator;
}
public function isReadyForCostCentre($grant)
{
foreach ($this->validators as $validator) {
/* @var Validator $validator */
if (!$validator->isValid($grant)) {
$this->setNotice($validator->getMessage());
return false;
}
}
$this->setNotice('');
return true;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment