/** * Stack constructor * * options - strict: throw errrors * * @param mixed $data the data to initialize the list with * @param array $options The options to give the object * */ public function __construct($data = null, $options = array()) { if (is_array($options)) { $options = array_change_key_case($options); } $this->configure($options); parent::__construct($data, $options); }
/** * AbstractRestrictedList Constructor * * Populates the internal member array, as well as the Predicate object * * Note: if no restrictions predicate object is given, a predicate object * inclusive of all types (except Type::TYPED_OBJECT) is generated * * Creates an empty list if no parameter given. * * * Options: strict - Do we raise appropriate exceptions when values * are misaligned? * * @param mixed $data The data to populate the internal member array * @param Falcraft\Data\Types\Resource\AbstractFilter $restrictions * The predicate type object * @param array $options The options for the array * * @throws Exception\InvalidArgumentException If an illegal value is * given to the object (not in restrictions) * */ public function __construct($data = null, AbstractFilter $restrictions = null, $options = array()) { if (is_array($options)) { $options = array_change_key_case($options); } $this->configure($options); // If there are no restrictions given, build basic free form restrictions // Default doesn't allow Type::TYPED_OBJECT if (!$restrictions) { $restrictions = Types\Restrictions::getDefaultRestrictions(); } $this->restrictions = $restrictions; if (is_array($data)) { // Plain Array /* Check input values for any illegal types If false, throw error because this is a constructor and can' really return anything. */ if (!Types\Restrictions::checkElements($data, $this->restrictions, $this->conf->strict)) { throw new Exception\InvalidArgumentException('AbstractRestrictedList->__construct: Illegal Value'); } } else { if ($data instanceof AbstractList) { // Falcraft\Data\Types\FList\AbstractList /* Check input values for any illegal types If false, throw error because this is a constructor and can't really return anything. */ if (!Types\Restrictions::checkElements($data->getList(), $this->restrictions, $this->conf->strict)) { throw new Exception\InvalidArgumentException('AbstractRestrictedList->__construct: Illegal Value'); } } else { if ($data) { // A scalar value /* Check input values for any illegal types If false, throw error because this is a constructor and can't really return nothing */ if (!Types\Restrictions::checkElements(array($data), $this->restrictions, $this->conf->strict)) { throw new Exception\InvalidArgumentException('AbstractRestrictedList->__construct: Illegal Value'); } } } } parent::__construct($data, $options); }