/**
  * Parameters setter.
  *
  * @param string $key   the parameter name to set, if NULL all the parameters array wil be set
  * @param mixed  $value the parameter value or all the parameters if $key is NULL
  *
  * @return AbstractClassContent
  */
 public function setParam($key, $value = null)
 {
     return null !== $this->getDraft() ? $this->getDraft()->setParam($key, $value) : parent::setParam($key, $value);
 }
Пример #2
0
 /**
  * Parameters setter.
  *
  * @param string $key   the parameter name to set, if NULL all the parameters array wil be set
  * @param mixed  $value the parameter value or all the parameters if $key is NULL
  *
  * @return AbstractClassContent
  */
 public function setParam($key, $value = null)
 {
     if (!isset($this->defaultParams[$key])) {
         throw new \InvalidArgumentException("Cannot set {$key} as parameter cause this key does not exist.");
     }
     if (is_object($value)) {
         throw new \InvalidArgumentException('Parameter\'s value cannot be type of object.');
     }
     $currentValue = $this->getParamValue($key);
     if (null !== $value && null !== $currentValue && (gettype($value) !== gettype($currentValue) && (!(is_string($value) || is_integer($value)) || !(is_string($currentValue) || is_integer($currentValue))))) {
         throw new \InvalidArgumentException(sprintf('Cannot replace %s\'s value, %s expected and %s given.', $key, gettype($currentValue), gettype($value)));
     }
     return null !== $this->getDraft() ? $this->getDraft()->setParam($key, $value) : parent::setParam($key, $value);
 }