/**
  * @param SerializeEvent $event
  */
 public function detect(SerializeEvent $event)
 {
     $subject = $event->getSubject();
     if (!is_object($subject)) {
         return;
     }
     $data =& $event->getData();
     $data['__type'] = get_class($event->getSubject());
 }
 public function extract(SerializeEvent $event)
 {
     $subject = $event->getSubject();
     $data =& $event->getData();
     $serializer = $event->getSerializer();
     if (!is_object($subject)) {
         throw new InvalidArgumentException(sprintf('$subject is expected to be an object, %s given', is_string($subject) ? $subject : gettype($subject)));
     }
     foreach ($this->ancestry(get_class($subject)) as $parent) {
         $this->serializers->locate($parent)->serialize($subject, $data, $serializer);
     }
 }
 public function encrypt(SerializeEvent $event)
 {
     $subject = $event->getSubject();
     $data =& $event->getData();
     $this->locator->locate(get_class($subject))->encrypt($data, $this->blockCypher);
 }