コード例 #1
0
 public function testReturnWhenValid()
 {
     $data = 'my data !';
     $parserMock = $this->getMockForAbstractClass('JSONSchema\\Parsers\\Parser');
     $parserMock->expects($this->once())->method('isValidType')->with($data)->willReturn(true);
     $sUT = new ParserFactory(array($parserMock));
     $this->assertEquals($parserMock, $sUT->getParser($data));
 }
コード例 #2
0
 /**
  * 
  * 
  * @param string $name
  * @param array $arguments
  * 	[0] == payload subject
  *  [1] == config params // not implemented yet 
  */
 public static function __callStatic($name, array $arguments)
 {
     if (!isset($arguments[0]) || !is_string($arguments[0])) {
         throw new \InvalidArgumentException("Key: subject must be included in the first position of the array arguments. Provided: " . serialize($arguments));
     }
     $parser = Parsers\ParserFactory::loadByPrefix($name, $arguments[0]);
     return $parser->parse()->json();
 }
コード例 #3
0
 /**
  * since we will probably use the example.address.json data all over the place lets go ahead and load it up 
  * 
  */
 public function setup()
 {
     $dataFile = realpath(__DIR__ . '/../../data/example.address1.json');
     if (!file_exists($dataFile)) {
         throw new \RuntimeException("The file: {$dataFile} does not exist");
     }
     // encoded and decoded to pack it down
     $this->addressJson1 = json_encode(json_decode(file_get_contents($dataFile)));
     $dataFile = realpath(__DIR__ . '/../../data/example.address2.json');
     if (!file_exists($dataFile)) {
         throw new \RuntimeException("The file: {$dataFile} does not exist");
     }
     $this->addressJson2 = json_encode(json_decode(file_get_contents($dataFile)));
     $this->parsers = ParserFactory::getParserTypes();
 }
コード例 #4
0
 /**
  * @param string $data
  * @return \JSONSchema\Structure\Schema
  */
 public function parse($data)
 {
     return $this->parserFactory->getParser($data)->parse($data);
 }