filesystem = $filesystem; $this->jsonParser = $jsonParser; } /** * @throws ParsingException */ public function lint(SplFileInfo $file): LintErrorsCollection { $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; } public function isInstalled(): bool { return class_exists(JsonParser::class); } public function setDetectKeyConflicts(bool $detectKeyConflicts): void { $this->detectKeyConflicts = $detectKeyConflicts; } private function calculateFlags(): int { $flags = 0; $flags += $this->detectKeyConflicts ? JsonParser::DETECT_KEY_CONFLICTS : 0; return $flags; } }