/**
  * @param string $profile
  *
  * @return ResolvedProfile
  */
 public function resolve(string $profile) : ResolvedProfile
 {
     if (!isset($this->profiles[$profile])) {
         throw new \InvalidArgumentException(sprintf('Unable to resolve unregistered profile "%s".', $profile));
     }
     $this->loader->clear();
     $this->loading = [$profile];
     $rootProfile = new Profile($profile, [], [], [], $this->variables, $this->defaults);
     $this->processProfile($rootProfile, $this->profiles[$profile]);
     $this->loading = [];
     $this->loader->loadGeneratorClasses(array_unique($rootProfile->generators));
     $this->loader->loadConfiguratorClasses(array_unique($rootProfile->configurators));
     return new ResolvedProfile($profile, $this->loader->getGenerators(), $this->loader->getConfigurators(), $rootProfile->variables, $rootProfile->defaults);
 }