/**
  * Serializes \Skrz\Meta\Fixtures\Protobuf\ClassWithVarintProperty to object
  *
  * @param ClassWithVarintProperty $object
  * @param string $group
  * @param array $filter
  *
  * @throws \Exception
  *
  * @return object
  */
 public static function toObject($object, $group = NULL, $filter = NULL)
 {
     if ($object === null) {
         return null;
     }
     if (!isset(self::$groups[$group])) {
         throw new \InvalidArgumentException('Group \'' . $group . '\' not supported for ' . 'Skrz\\Meta\\Fixtures\\Protobuf\\ClassWithVarintProperty' . '.');
     } else {
         $id = self::$groups[$group];
     }
     if (!$object instanceof ClassWithVarintProperty) {
         throw new \InvalidArgumentException('You have to pass object of class Skrz\\Meta\\Fixtures\\Protobuf\\ClassWithVarintProperty.');
     }
     if (Stack::$objects === null) {
         Stack::$objects = new \SplObjectStorage();
     }
     if (Stack::$objects->contains($object)) {
         return null;
     }
     Stack::$objects->attach($object);
     try {
         $output = array();
         if (($id & 1) > 0 && ($filter === null || isset($filter['x']))) {
             $output['x'] = $object->x;
         }
     } catch (\Exception $e) {
         Stack::$objects->detach($object);
         throw $e;
     }
     Stack::$objects->detach($object);
     return (object) $output;
 }
Beispiel #2
0
 /**
  * Serializes \Skrz\Bundle\BunnyBundle\Tests\Fixtures\Message to object
  *
  * @param Message $object
  * @param string $group
  * @param array $filter
  *
  * @throws \Exception
  *
  * @return object
  */
 public static function toObject($object, $group = NULL, $filter = NULL)
 {
     if ($object === null) {
         return null;
     }
     if (!isset(self::$groups[$group])) {
         throw new \InvalidArgumentException('Group \'' . $group . '\' not supported for ' . 'Skrz\\Bundle\\BunnyBundle\\Tests\\Fixtures\\Message' . '.');
     } else {
         $id = self::$groups[$group];
     }
     if (!$object instanceof Message) {
         throw new \InvalidArgumentException('You have to pass object of class Skrz\\Bundle\\BunnyBundle\\Tests\\Fixtures\\Message.');
     }
     if (Stack::$objects === null) {
         Stack::$objects = new \SplObjectStorage();
     }
     if (Stack::$objects->contains($object)) {
         return null;
     }
     Stack::$objects->attach($object);
     try {
         $output = array();
         if (($id & 1) > 0 && ($filter === null || isset($filter['intValue']))) {
             $output['intValue'] = $object->intValue;
         }
         if (($id & 2) > 0 && (isset($object->intValue) && $filter === null || isset($filter['intValue']))) {
             $output['intValue'] = $object->intValue;
         }
         if (($id & 1) > 0 && ($filter === null || isset($filter['floatValue']))) {
             $output['floatValue'] = $object->floatValue;
         }
         if (($id & 2) > 0 && (isset($object->floatValue) && $filter === null || isset($filter['floatValue']))) {
             $output['floatValue'] = $object->floatValue;
         }
         if (($id & 1) > 0 && ($filter === null || isset($filter['stringValue']))) {
             $output['stringValue'] = $object->stringValue;
         }
         if (($id & 2) > 0 && (isset($object->stringValue) && $filter === null || isset($filter['stringValue']))) {
             $output['stringValue'] = $object->stringValue;
         }
     } catch (\Exception $e) {
         Stack::$objects->detach($object);
         throw $e;
     }
     Stack::$objects->detach($object);
     return (object) $output;
 }