Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
5 / 5
100.00% covered (success)
100.00%
1 / 1
CRAP
100.00% covered (success)
100.00%
1 / 1
YamlParser
100.00% covered (success)
100.00%
5 / 5
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
1 / 1
 parse
100.00% covered (success)
100.00%
5 / 5
100.00% covered (success)
100.00%
1 / 1
1
1<?php declare(strict_types=1);
2/*
3 * This file is part of Aplus Framework Config Library.
4 *
5 * (c) Natan Felles <natanfelles@gmail.com>
6 *
7 * For the full copyright and license information, please view the LICENSE
8 * file that was distributed with this source code.
9 */
10namespace Framework\Config\Parsers;
11
12/**
13 * Class YamlParser.
14 *
15 * @package config
16 */
17class YamlParser extends Parser
18{
19    /**
20     * Parses an YAML file.
21     *
22     * @param mixed $config path to the YAML file
23     *
24     * @throws ParserException
25     *
26     * @return array<mixed> The YAML parsed data
27     */
28    public static function parse(mixed $config) : array
29    {
30        static::checkConfig($config);
31        return static::parseOrThrow(static function () use ($config) : array {
32            $data = \yaml_parse_file($config);
33            return static::ksortRecursive($data);
34        });
35    }
36}