Ejemplo n.º 1
0
 public function testSetParam()
 {
     $payload = new Payload();
     $this->assertNull($payload->getParam('foo'));
     $payload->setParam('foo', 'bar');
     $this->assertSame('bar', $payload->getParam('foo'));
 }
Ejemplo n.º 2
0
 /**
  * {@inheritdoc}
  * @see \InoPerunApi\Client\Serializer\SerializerInterface::unserialize()
  */
 public function unserialize($data, Payload $payload)
 {
     try {
         $params = $this->jsonDecode($data);
     } catch (\Exception $e) {
         throw new Exception\UnserializeException(sprintf("JSON decode exception: [%s] %s", get_class($e), $e->getMessage()));
     }
     if (null !== $params) {
         if (is_array($params)) {
             $payload->setParams($params);
         } else {
             throw new Exception\UnexpectedResultException('Invalid unserialized data - must be array or null');
         }
     }
     return $payload;
 }
Ejemplo n.º 3
0
 /**
  * {@inheritdoc}
  * @see \InoPerunApi\Entity\Factory\FactoryInterface::createFromResponsePayload()
  */
 public function createFromResponsePayload(Payload $payload)
 {
     return $this->create($payload->getParams());
 }