/**
  * @param $json
  * @return \MetaPlayer\Contract\AssociationDto
  * @throws \MetaPlayer\JsonException
  */
 private function parseJson($json)
 {
     $associationDto = $this->jsonUtils->deserialize($json);
     if (!$associationDto instanceof AssociationDto) {
         $this->logger->error("json should be instance of AssociationDto but got " . print_r($associationDto, true));
         throw new JsonException("Wrong json format.");
     }
     return $associationDto;
 }
 /**
  * @param $json
  * @return PlayerState
  * @throws \MetaPlayer\JsonException
  */
 private function parseJson($json)
 {
     $playerState = $this->jsonUtils->deserialize($json);
     if (!$playerState instanceof PlayerState) {
         $this->logger->error("json should be instance of PlayerState but got " . print_r($playerState, true));
         throw new JsonException("Wrong json format.");
     }
     return $playerState;
 }
Esempio n. 3
0
 /**
  * @param $json
  * @return \MetaPlayer\Contract\BandDto
  * @throws \MetaPlayer\JsonException
  */
 private function convertJson($json)
 {
     $bandDto = $this->jsonUtils->deserialize($json);
     /* @var $bandDto BandDto */
     if (!$bandDto instanceof BandDto) {
         $this->logger->error("json should be instance of BandDto but got " . print_r($bandDto, true));
         throw new JsonException("Wrong json format.");
     }
     return $bandDto;
 }
Esempio n. 4
0
 /**
  * @covers {className}::{origMethodName}
  * @todo Implement testSerialize().
  */
 public function testSerialize()
 {
     $dto = new BandDto();
     $dto->id = 100500;
     $dto->name = "abc";
     $dto->foundDate = ViewHelper::formatDate(new \DateTime());
     $dto->endDate = array($dto, 'date', 'other date');
     $json = $this->object->serialize($dto);
     $deser = $this->object->deserialize($json);
     $this->assertTrue($deser instanceof BandDto);
     $this->assertEquals($dto->id, $deser->id);
     $this->assertTrue($deser->endDate[0] instanceof BandDto);
     $this->assertEquals($dto->id, $deser->endDate[0]->id);
 }