*/ final class YamlSource implements IteratorAggregate { /** @var iterable */ private iterable $source; /** * @throws InvalidSource */ public function __construct(string $yamlSource) { /** @infection-ignore-all */ // @codeCoverageIgnoreStart if (! function_exists('yaml_parse')) { throw new YamlExtensionNotEnabled(); } // @codeCoverageIgnoreEnd $source = @yaml_parse($yamlSource); if ($source === false) { throw new InvalidYaml($yamlSource); } if (! is_iterable($source)) { throw new SourceNotIterable($yamlSource); } $this->source = $source; } /** * @return Iterator */ public function getIterator(): Traversable { yield from $this->source; } }