protected function generateStringSchema(string $stringValue): array
    {
        $schema = ['type' => 'string'];
        $schemaValidator = new SchemaValidator();
        $detectedFormat = null;

        $detectableFormats = ['uri','email','ip-address','class-name','interface-name'];
        foreach ($detectableFormats as $testFormat) {
            $testSchema = ['type' => 'string', 'format' => $testFormat];
            $result = $schemaValidator->validate($stringValue, $testSchema);
            if ($result->hasErrors() === false) {
                $detectedFormat = $testFormat;
            }
        }
        if ($detectedFormat !== null) {
            $schema['format'] = $detectedFormat;
        }
        return $schema;
    }
protected function generateStringSchema(string $stringValue): array
    {
        $schema = ['type' => 'string'];
        $schemaValidator = new SchemaValidator();
        $detectedFormat = null;

        $detectableFormats = ['uri','email','ip-address','class-name','interface-name'];
        foreach ($detectableFormats as $testFormat) {
            $testSchema = ['type' => 'string', 'format' => $testFormat];
            $result = $schemaValidator->validate($stringValue, $testSchema);
            if ($result->hasErrors() === false) {
                $detectedFormat = $testFormat;
            }
        }
        if ($detectedFormat !== null) {
            $schema['format'] = $detectedFormat;
        }
        return $schema;
    }
protected function generateStringSchema ( string $ stringValue ) : array { $ schema = [ 'type' => 'string' ] ; $ schemaValidator = new SchemaValidator ( ) ; $ detectedFormat = null ; $ detectableFormats = [ 'uri' , 'email' , 'ip-address' , 'class-name' , 'interface-name' ] ; foreach ( $ detectableFormats as $ testFormat ) { $ testSchema = [ 'type' => 'string' , 'format' => $ testFormat ] ; $ result = $ schemaValidator -> validate ( $ stringValue , $ testSchema ) ; if ( $ result -> hasErrors ( ) === false ) { $ detectedFormat = $ testFormat ; } } if ( $ detectedFormat !== null ) { $ schema [ 'format' ] = $ detectedFormat ; } return $ schema ; }
Create a schema for a given string

@param string $stringValue
@return array
Create a schema for a given string