Example #1
0
 /**
  * Convert a JSON string to an array.
  *
  * {@inheritDoc}
  */
 public static function decode($string)
 {
     if (!$string) {
         return new ArrayObject();
     }
     $array = json_decode($string, true);
     static::checkLastError();
     if (!is_array($array)) {
         $array = [];
     }
     return ArrayObject::make($array);
 }
Example #2
0
 /**
  * Convert a php serialized string to an array.
  *
  * {@inheritDoc}
  */
 public static function decode($string)
 {
     if (!$string) {
         return new ArrayObject();
     }
     try {
         $array = unserialize($string);
     } catch (\Exception $e) {
         throw new PhpException("Serialize Error: " . $e->getMessage());
     }
     if (!is_array($array)) {
         $array = [];
     }
     return ArrayObject::make($array);
 }