code: private function read(string $file, string $reader)
      {
          if (!is_readable($file) || false === ($content = file_get_contents($file))) {
              throw new RuntimeException('Configuration file does not exists or can not be read');
          }
  
          $wrongFileException = new RuntimeException('Configuration file can not be parsed');
  
          switch ($reader) {
              case 'yaml':
                  $data = Yaml::parse($content);
                  break;
              case 'json':
                  $data = json_decode($content, true);
                  break;
              default:
                  throw $wrongFileException;
          }
  
          if (!\is_array($data)) {
              throw $wrongFileException;
          }
  
          return $this->parse($data);
      }
docs: @param string $file
  @param string $reader
  
  @return Collection