Esempio n. 1
0
 public function getErrors()
 {
     if (isset($this->report)) {
         return $this->report->getErrors();
     } else {
         return [];
     }
 }
Esempio n. 2
0
 public function getSchemaByUri(Report $report, $uri, $root = null)
 {
     $remotePath = $this->getRemotePath($uri);
     $queryPath = $this->getQueryPath($uri);
     $result = null;
     if (empty($remotePath)) {
         $result = $root;
     } else {
         if (isset($this->cache[$remotePath])) {
             $result = $this->cache[$remotePath];
         }
     }
     if (!empty($result) && !empty($remotePath) && $result !== $root) {
         $report->pathPush($remotePath);
         $remoteReport = new Report($report);
         if ($this->statham->compiler->compileSchema($remoteReport, $result, $this)) {
             $this->statham->schemaValidator->validateSchema($remoteReport, $result, $this);
         }
         $remoteReportIsValid = $remoteReport->isValid();
         if (!$remoteReportIsValid) {
             $report->addError('REMOTE_NOT_VALID', [$uri], $remoteReport);
         }
         $report->pathPop();
         if (!$remoteReportIsValid) {
             return null;
         }
     }
     if (!empty($result) && !empty($queryPath)) {
         $parts = explode('/', $queryPath);
         for ($i = 0, $lim = count($parts); $i < $lim; $i++) {
             $key = $this->decodeJSONPointer($parts[$i]);
             if ($i === 0) {
                 $result = $this->findId($result, $key);
             } else {
                 if (isset($result->{$key})) {
                     $result = $result->{$key};
                 }
             }
         }
     }
     return $result;
 }
Esempio n. 3
0
 public function isFormat(Report $report, $schema, $key)
 {
     if (!is_string($schema->{$key})) {
         $report->addError('KEYWORD_TYPE_EXPECTED', [$key, 'string']);
     } else {
         //@todo implement format validators
     }
 }