YAML
class YAML (View source)
The GenericDatabase\Helpers\Parsers\YAML class provides validation and parsing functionalities for YAML strings.
It contains two static methods: isValidYAML and parseYAML.
Example Usage:
// Validate a YAML string
$yaml = 'example.yaml';
$isValidYAML = \GenericDatabase\Helpers\YAML::isValidYAML($yaml);
$isValidYAML will be true if the YAML string is valid, false otherwise
// Parse a YAML string
$value = 'true';
$yaml = 'example.yaml';
$parsedYAML = \GenericDatabase\Helpers\YAML::parseYAML($yaml);
$parsedYAML will be an array containing the parsed YAML data
Main functionalities:
- The
isValidYAMLmethod checks if a YAML string is valid by verifying that it is a string and ends with the extension '.yaml'. It also uses theyaml_parse_filefunction to further validate the YAML syntax. - The
parseYAMLmethod parses a valid YAML string by using theyaml_parse_filefunction and returns the parsed data as an array.
Methods:
isValidYAML(mixed $yaml): bool: Checks if a YAML string is valid.parseYAML(string $yaml): array: Parses a valid YAML string and returns the parsed data as an array.
Methods
static bool
isValidYAML(mixed $yaml)
Check if yaml string is valid
static array
parseYAML(string $yaml)
Parse a valid yaml string
Details
static bool
isValidYAML(mixed $yaml)
Check if yaml string is valid
static array
parseYAML(string $yaml)
Parse a valid yaml string