/** * Override the DataContainer's set function to enable type checking. * * @param string $key * @param Option $value * * @return $this * * @throws InvalidArgumentException * * @since 2.0 */ public function set($key, $value) { if (!$value instanceof Option) { throw new InvalidArgumentException('Only Options can be added to an Optgroup.'); } return parent::set($key, $value); }
/** * Overrides the set method from DataContainer to ensure only Cells can be added * * @throws \InvalidArgumentException */ public function set($key, $value) { if (!$value instanceof Cell) { throw new \InvalidArgumentException('Only Cells can be added to Rows'); } parent::set($key, $value); }
/** * Override the DataContainer's set function to enable type checking. * * @param string $key * @param Option|Optgroup $value * * @return $this * * @throws \InvalidArgumentException * * @since 2.0 */ public function set($key, $value) { if (!$value instanceof Option && !$value instanceof Optgroup) { throw new \InvalidArgumentException('Only Options or Optgroups can be added to a Select.'); } parent::set($key, $value); return $this; }
/** * Sets a config value * * @param string $key * @param mixed $value * @param integer $expiry * * @throws \RuntimeException */ public function set($key, $value, $expiry = null) { // make sure we have a valid key if ($key === null) { throw new \RuntimeException('No valid key passed to set()'); } // and store the value passed parent::set($this->prefixKey($key), $value); }
/** * Sets a config value * * @param string $key * @param mixed $value * @param integer $expiry * * @throws \RuntimeException */ public function set($key, $value, $expiry = null) { // make sure we have a valid key if ($key === null) { throw new \RuntimeException('No valid key passed to setFlash()'); } // get the default expiry if none is given $expiry === null and $expiry = $this->defaultExpiryState; // validate the expiry if (!in_array($expiry, $this->expiryStates)) { throw new \RuntimeException('"' . $expiry . '" is not a valid session flash variable expiration state.'); } // store the expiry information for this key $this->data[static::EXPIRE_DATA_KEY][$key] = array($expiry, static::EXPIRE_STATE_NEW); // and store the value passed parent::set($this->prefixKey($key), $value); }
/** * Extends DataContainer's set method to ensure only Toggle objects can be added. * * @param string $key * @param mixed $value * * @return $this * * @throws \InvalidArgumentException * * @since 2.0 */ public function set($key, $value) { if (!$value instanceof Toggle) { throw new \InvalidArgumentException('You can only add Toggle objects to a ToggleGroup.'); } return parent::set($key, $value); }
/** * Sets view data * * @param string|array $key * @param mixed $value * @param boolean $filter * * @return $this */ public function set($key, $value = null, $filter = null) { parent::set($key, $value); if (is_array($key)) { if (is_bool($value)) { $filter = $value; } foreach ($key as $_key => $_value) { $this->filterIndex[$_key] = $filter; } } else { $this->filterIndex[$key] = $filter; } return $this; }
/** * @group Common */ public function testIsModified() { $c = new DataContainer(array('yes' => true)); $this->assertFalse($c->isModified()); $c->set('yes', false); $this->assertTrue($c->isModified()); }
/** * The given value must be an instance of the $modelClass * * @inheritdoc */ public function set($key, $value) { $targetClass = $this->getModelClass(); if (!is_object($value) or !$value instanceof $targetClass) { $actualClass = gettype($value); if (is_object($value)) { $actualClass = get_class($value); } throw new InvalidArgumentException('ORM-005: Invalid model instance. Expecting [' . $this->getModelClass() . '] got [' . $actualClass . ']'); } if ($value->getProvider() === null and $this->getProvider() !== null) { $value->setProvider($this->getProvider()); } return parent::set($key, $value); }