00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00018 abstract class RegulatedForm extends PlainForm
00019 {
00020 protected $rules = array();
00021 protected $violated = array();
00022
00027 public function addRule($name, LogicalObject $rule)
00028 {
00029 Assert::isString($name);
00030
00031 $this->rules[$name] = $rule;
00032
00033 return $this;
00034 }
00035
00040 public function dropRuleByName($name)
00041 {
00042 if (isset($this->rules[$name])) {
00043 unset($this->rules[$name]);
00044 return $this;
00045 }
00046
00047 throw new MissingElementException(
00048 "no such rule with '{$name}' name"
00049 );
00050 }
00051
00055 public function checkRules()
00056 {
00057 foreach ($this->rules as $name => &$logicalObject) {
00058 if (!$logicalObject->toBoolean($this))
00059 $this->violated[$name] = Form::WRONG;
00060 }
00061
00062 return $this;
00063 }
00064 }
00065 ?>