static function fromYaml(string $document): self {
    if (!mb_strlen($document)) throw new \InvalidArgumentException('The specified YAML document is empty.');

    try {
      $yaml = Yaml::parse($document);
      if (!is_array($yaml)) throw new \InvalidArgumentException('The specified YAML document is invalid.');
      return new static($yaml);
    }

    catch (ParseException $e) {
      throw new \InvalidArgumentException('The specified YAML document is invalid.', 0, $e);
    }
  }