protected function parseImports(RepositoryInterface $repository, string $file) : RepositoryInterface
    {
        if (!isset($repository[self::IMPORT_KEY])) {
            return $repository;
        }

        if (!is_array($repository[self::IMPORT_KEY])) {
            $keyName = self::IMPORT_KEY;
            $message = "The \"{$keyName}\" key should contain an array in {$file}. Check your YAML syntax.";
            throw new \InvalidArgumentException($message);
        }

        foreach ($repository[self::IMPORT_KEY] as $import) {
            if (!is_array($import)) {
                $import = ['resource' => $import];
            }
            
            $ignoreErrors = isset($import['ignore_errors']) ? (bool) $import['ignore_errors'] : false;

            $importedResource = $this->import($import['resource'], null, $ignoreErrors, $file);

            if ($importedResource) {
                $repository = $repository->union($importedResource);
            }
        }

        $repository->del(self::IMPORT_KEY);

        return $repository;
    }