/** * setState (convert from array to object). * * @return string */ public static function __set_state($array) { $receiverProperty = new self(); $receiverProperty->setFieldName($array['fieldName']); $receiverProperty->setRequired($array['required']); return $receiverProperty; }
/** * @param string $key Input field key * @param string $type Input field type * @param array $options */ public function add($key, $type = self::TYPE_STRING, $options = []) { $node = new self(); $node->setType($type); if (isset($options['required'])) { $node->setRequired($options['required']); } if (isset($options['constraints'])) { $node->setConstraints($options['constraints']); } $this->offsetSet($key, $node); return $node; }
/** * Factory method * * @param array $aRequired array of required * params * * @return object of this class */ public static function factory(array $aRequired = array()) { $a = null; $req = self::getRequestMethod(); if ('POST' === $req) { $a = $_POST; } elseif ('GET' === $req) { $a = $_GET; } $o = new self($a); $o->setRequired($aRequired); $o->checkRequired(); return $o; }