Exemplo n.º 1
0
 /**
  * Sets the value of the header field.
  *
  * Accepts either strings or objects of type \Ableron\Lib\Net\Uri.
  *
  * @param string|\Ableron\Lib\Net\Uri $fieldValue The field value to set
  * @throws \Ableron\Core\Exception\SystemException
  * @return void
  */
 public function setFieldValue($fieldValue)
 {
     if (is_string($fieldValue)) {
         $this->fieldValue = new Uri($fieldValue);
     } elseif ($fieldValue instanceof Uri) {
         $this->fieldValue = $fieldValue;
     } else {
         throw new SystemException(sprintf('Unable to set header field value to %s - Field value must be a string or an object of type \\Ableron\\Lib\\Net\\Uri. Given: %s', StringUtil::toString($fieldValue), gettype($fieldValue)), 0, E_USER_WARNING, __FILE__, __LINE__);
     }
 }
Exemplo n.º 2
0
 /**
  * @see \Ableron\Lib\Collections\Interfaces\SetInterface::add()
  * @throws \Ableron\Core\Exception\SystemException In case the given element does not fit the element type of this set
  */
 public function add($element)
 {
     // check whether given element is an object
     if (!is_object($element)) {
         throw new SystemException(sprintf('Unable to add non-object to object set: %s', StringUtil::toString($element)), 0, E_USER_WARNING, __FILE__, __LINE__);
     }
     // check whether given element has the correct type
     if ($this->elementType !== null && !$element instanceof $this->elementType) {
         throw new SystemException(sprintf('Unable to add object of type %s to object set of type %s', get_class($element), $this->elementType), 0, E_USER_WARNING, __FILE__, __LINE__);
     }
     // add given element to set
     parent::add($element);
 }
Exemplo n.º 3
0
 /**
  * @see \Ableron\Lib\Stdlib\Interfaces\HeaderFieldInterface::addFieldValue()
  */
 public function addFieldValue($fieldValue)
 {
     // get current field value
     $currentFieldValue = $this->fieldValue;
     // try to set field value
     try {
         // check whether field value is valid
         $this->setFieldValue($fieldValue);
         // combine old and new field value
         if ($currentFieldValue !== null) {
             $this->fieldValue = sprintf('%s, %s', $currentFieldValue, $this->fieldValue);
         }
     } catch (SystemException $e) {
         throw new SystemException(sprintf('Unable to add header field value %s', StringUtil::toString($fieldValue)), 0, E_USER_WARNING, __FILE__, __LINE__, $e);
     }
 }
Exemplo n.º 4
0
 /**
  * Sets the protocol port of this URI.
  *
  * Accepts any integer between 1 and 65535.
  *
  * Throws an exception in case the given port is invalid.
  *
  * @param int|null $port The protocol port to set
  * @throws \Ableron\Core\Exception\SystemException
  * @return void
  */
 public function setPort($port)
 {
     if ($port !== null && !self::isValidPort($port)) {
         throw new SystemException(sprintf('Unable to set URI protocol port to %s - Invalid protocol port!', StringUtil::toString($port)), 0, E_USER_NOTICE, __FILE__, __LINE__);
     }
     $this->port = $port;
 }
Exemplo n.º 5
0
 /**
  * Returns the arguments of the template tag.
  *
  * @return \Ableron\Lib\Collections\Implementations\CaseInsensitiveKeysMap
  */
 public function getArgumentsAsPhpString()
 {
     // init list of PHP arguments
     $phpArguments = array();
     // add parameters, one by one
     foreach ($this->arguments as $argumentName => $argumentValue) {
         $phpArguments[] = StringUtil::toString($argumentName) . ' => ' . $argumentValue;
     }
     // return PHP string
     return sprintf('[ %s ]', implode(', ', $phpArguments));
 }