示例#1
0
 /**
  * Wrap value in AeType instance
  *
  * This method selects the respective class and wraps the passed value using
  * that class. If the value passed is not a type value, original value is
  * returned. Type values are null, boolean, integer, float, string and array
  * values.
  *
  * @param mixed $value
  *
  * @return AeType|false
  */
 public static function wrap($value)
 {
     if ($value instanceof AeType) {
         return $value;
     }
     if (is_null($value)) {
         return new AeNull();
     }
     if (is_scalar($value)) {
         return AeScalar::wrap($value);
     }
     if (is_array($value)) {
         return new AeArray($value);
     }
     return $value;
 }
示例#2
0
 /**
  * Get cookie value
  *
  * Returns the value of the cookie, identified by <var>$name</var> parameter,
  * or <var>$default</var>, if that cookie is not set. Also clears the cookie
  * value, removing any null bytes and slashes, added by magic quotes (if the
  * latter setting is enabled).
  *
  * The return value is wrapped inside the respective wrapper class. The
  * default value is not wrapped
  *
  * @param string $name
  * @param mixed  $default
  *
  * @return AeArray|AeScalar
  */
 public static function get($name, $default)
 {
     if (!isset($_COOKIE[(string) $name])) {
         return $default;
     }
     $value = self::_tidy($_COOKIE[(string) $name]);
     if (is_array($value)) {
         return new AeArray($value);
     }
     return AeScalar::wrap($value);
 }