public function testSetParam() { $payload = new Payload(); $this->assertNull($payload->getParam('foo')); $payload->setParam('foo', 'bar'); $this->assertSame('bar', $payload->getParam('foo')); }
/** * {@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; }
/** * {@inheritdoc} * @see \InoPerunApi\Entity\Factory\FactoryInterface::createFromResponsePayload() */ public function createFromResponsePayload(Payload $payload) { return $this->create($payload->getParams()); }