GrumPHP\Linter\Json\JsonLinter::lint PHP Method

lint() public method

public lint ( SplFileInfo $file ) : mixed
$file SplFileInfo
return mixed
    public function lint(SplFileInfo $file)
    {
        $errors = new LintErrorsCollection();
        $flags = $this->calculateFlags();
        try {
            $json = $this->filesystem->readFromFileInfo($file);
            $this->jsonParser->parse($json, $flags);
        } catch (ParsingException $exception) {
            $errors->add(JsonLintError::fromParsingException($file, $exception));
        }
        return $errors;
    }

Usage Example

Esempio n. 1
0
 /**
  * @param string $fixture
  * @param int $errors
  */
 private function validateFixture($fixture, $errors)
 {
     $result = $this->linter->lint($this->getFixture($fixture));
     $this->assertInstanceOf(LintErrorsCollection::class, $result);
     $this->assertEquals($result->count(), $errors, 'Invalid error-count expected.');
     if ($result->count()) {
         $this->assertInstanceOf(JsonLintError::class, $result[0]);
     }
 }
All Usage Examples Of GrumPHP\Linter\Json\JsonLinter::lint