Created
February 6, 2011 17:52
-
-
Save kriswallsmith/813559 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
| <?php | |
| interface Configurable | |
| { | |
| static function getOptionsBag(); | |
| } | |
| class Form implements Configurable | |
| { | |
| public function __construct($options = array()) | |
| { | |
| $this->options = static::getOptionsBag()->process($options); | |
| } | |
| static public function getOptionsBag() | |
| { | |
| return OptionsBag::create() | |
| ->addRequiredOption('foo') | |
| ->addOption('bar', 'blah') | |
| ; | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The code is so unexplicit, when your field wiggles with 20 or something options is really bad to read getOption('a') getOption('b)' only ... and so on.
Why the static bag btw? Is there any metadata need for this? I can't really see it yet.