/** * * @param string $jsonString * @return boolean */ public function parseTradeMessage($jsonString) { // TODO: Usually we'd use some sort of tradeMessage model here to validate // the data structure $messageData = Places\Transform::jsonToArray($jsonString); // TODO: We should also sanitize the content of the JSON by checking for expected types return $this->passMessageToSocketServer($messageData); }
/** * * @dataProvider getJsonTestData * @test */ public function jsonToArrayTest($testJson, $expectedPass) { $array = \PlaceFinder\Places\Transform::jsonToArray($testJson); if (!$expectedPass) { $this->assertEmpty($array); } else { $this->assertCount(1, $array); } }