Created
April 11, 2013 14:53
-
-
Save Tocacar/5364044 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| 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