示例#1
0
 /**
  * Wrap return
  *
  * This method wraps (or unwraps) the value passed according to all the
  * <var>$wrapReturn</var> settings.
  *
  * @param mixed $value
  * @param mixed $default
  *
  * @return mixed
  */
 public static function wrapReturn($value, $default = null)
 {
     if ($value instanceof AeType) {
         $value = $value->getValue() === null ? $default : $value;
     } else {
         $value = $value === null ? $default : $value;
     }
     if (self::of($value) != 'object') {
         // *** Wrap, if enabled
         if (self::$wrapReturn === true && !$value instanceof AeType) {
             return self::wrap($value);
         }
         // *** Detect further down the class tree
         if (self::$wrapReturn === null) {
             if (is_scalar($value) || $value instanceof AeScalar) {
                 return AeScalar::_wrapReturn($value);
             }
             if (is_array($value) || $value instanceof AeArray) {
                 return AeArray::_wrapReturn($value);
             }
         }
         // *** Unwrap if disabled
         if (self::$wrapReturn === false && $value instanceof AeType) {
             return $value->getValue();
         }
     }
     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);
 }