コード例 #1
0
 public function testSetParam()
 {
     $payload = new Payload();
     $this->assertNull($payload->getParam('foo'));
     $payload->setParam('foo', 'bar');
     $this->assertSame('bar', $payload->getParam('foo'));
 }
コード例 #2
0
ファイル: Json.php プロジェクト: ivan-novakov/php-perun-api
 /**
  * {@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;
 }
コード例 #3
0
 /**
  * {@inheritdoc}
  * @see \InoPerunApi\Entity\Factory\FactoryInterface::createFromResponsePayload()
  */
 public function createFromResponsePayload(Payload $payload)
 {
     return $this->create($payload->getParams());
 }