Exemple #1
0
 private function resolve($schema, $parents = array())
 {
     $result = $schema;
     if ($ref = JsonUtils::get($schema, '$ref')) {
         $refSchema = JsonUtils::get($this->references, $ref);
         if (in_array($ref, $parents)) {
             throw new \RuntimeException('Circular reference to ref ' . $ref);
         } elseif (JsonUtils::get($refSchema, '$ref')) {
             $parents[] = $ref;
             $result = $this->resolve($refSchema, $parents);
         } else {
             $result = $refSchema;
         }
     }
     return $result;
 }
Exemple #2
0
 protected function validateUnique($data)
 {
     $count = count($data);
     for ($i = 0; $i < $count; ++$i) {
         for ($j = $i + 1; $j < $count; ++$j) {
             if (JsonUtils::equals($data[$i], $data[$j])) {
                 return false;
             }
         }
     }
     return true;
 }