Composer\Satis\Console\Command\BuildCommand::check PHP Метод

check() приватный Метод

Validates the syntax and the schema of the current config json file according to satis-schema.json rules.
private check ( string $configFile ) : boolean
$configFile string The json file to use
Результат boolean true on success
    private function check($configFile)
    {
        $content = file_get_contents($configFile);
        $parser = new JsonParser();
        $result = $parser->lint($content);
        if (null === $result) {
            if (defined('JSON_ERROR_UTF8') && JSON_ERROR_UTF8 === json_last_error()) {
                throw new \UnexpectedValueException('"' . $configFile . '" is not UTF-8, could not parse as JSON');
            }
            $data = json_decode($content);
            $schemaFile = __DIR__ . '/../../../res/satis-schema.json';
            $schema = json_decode(file_get_contents($schemaFile));
            $validator = new Validator();
            $validator->check($data, $schema);
            if (!$validator->isValid()) {
                $errors = [];
                foreach ((array) $validator->getErrors() as $error) {
                    $errors[] = ($error['property'] ? $error['property'] . ' : ' : '') . $error['message'];
                }
                throw new JsonValidationException('The json config file does not match the expected JSON schema', $errors);
            }
            return true;
        }
        throw new ParsingException('"' . $configFile . '" does not contain valid JSON' . "\n" . $result->getMessage(), $result->getDetails());
    }