public function testGetData() { $object = new User(); $object->setId(3); $object->setAlias('the-doctor'); $object->setName('Tenth'); $object->setEmail('*****@*****.**'); $data = ['id' => 3, 'alias' => 'the-doctor', 'name' => 'Tenth', 'email' => '*****@*****.**']; $this->assertInternalType('array', $this->object->getData($object)); $this->assertSame($data, $this->object->getData($object)); }
/** * Serializes Object * * @param Map $map the object structure map * @param object $object candidate to serialize * * @return mixed */ public function serialize(Map $map, $object) { $identifier = $map->getIdentifier(); $data = $map->getData($object); if (!isset($data[$identifier]) || !$data[$identifier]) { $id = spl_object_hash($object); $reflection = new \ReflectionProperty($map->getLocalName(), $identifier); $reflection->setAccessible(true); $reflection->setValue($object, $id); } return serialize($object); }