original_string: public function validateJson(string $json, string $schemaName): ValidationResult
      {
          $schemaDir = $this->config->get('schema-dir');
          $schemaPath = $this->configDirectoryPath.$schemaDir.'/'.$schemaName.'.json';
          if(!file_exists($schemaPath)){
              throw new FileNotFoundException("File $schemaPath not found");
          }
          
          $schemaJsonString = file_get_contents($schemaPath);
          $decodedJson = json_decode($json);
          if ($decodedJson === false) {
              $schema = json_decode($schemaJsonString);
              // error decoding json
              return (new ValidationResult())
                  ->addError(new ValidationError($json,
                          [],
                          [],
                          $schema,
                          "Failed to decode JSON string")
                  );
          }
          return $this->dataValidation($decodedJson, $schemaJsonString);
      }
code: public function validateJson(string $json, string $schemaName): ValidationResult
      {
          $schemaDir = $this->config->get('schema-dir');
          $schemaPath = $this->configDirectoryPath.$schemaDir.'/'.$schemaName.'.json';
          if(!file_exists($schemaPath)){
              throw new FileNotFoundException("File $schemaPath not found");
          }
          
          $schemaJsonString = file_get_contents($schemaPath);
          $decodedJson = json_decode($json);
          if ($decodedJson === false) {
              $schema = json_decode($schemaJsonString);
              // error decoding json
              return (new ValidationResult())
                  ->addError(new ValidationError($json,
                          [],
                          [],
                          $schema,
                          "Failed to decode JSON string")
                  );
          }
          return $this->dataValidation($decodedJson, $schemaJsonString);
      }
code_tokens: public function validateJson ( string $ json , string $ schemaName ) : ValidationResult { $ schemaDir = $ this -> config -> get ( 'schema-dir' ) ; $ schemaPath = $ this -> configDirectoryPath . $ schemaDir . '/' . $ schemaName . '.json' ; if ( ! file_exists ( $ schemaPath ) ) { throw new FileNotFoundException ( "File $schemaPath not found" ) ; } $ schemaJsonString = file_get_contents ( $ schemaPath ) ; $ decodedJson = json_decode ( $ json ) ; if ( $ decodedJson === false ) { $ schema = json_decode ( $ schemaJsonString ) ; // error decoding json return ( new ValidationResult ( ) ) -> addError ( new ValidationError ( $ json , [ ] , [ ] , $ schema , "Failed to decode JSON string" ) ) ; } return $ this -> dataValidation ( $ decodedJson , $ schemaJsonString ) ; }
docstring: Validates JSON strings against a schema.
  @param string $json
  @param string $schemaName Name of the .json file providing the schema (without file extension)
  @return ValidationResult
docstring_tokens: Validates JSON strings against a schema .