/** * @param string $index * @param Project $newval * * @throws \InvalidArgumentException */ public function offsetSet($index, $newval) { if (false === $newval instanceof Project) { throw new \InvalidArgumentException('value must be instance of \\Crane\\Configuration\\Project'); } if ($index != $newval->getName()) { throw new \InvalidArgumentException('\\Crane\\Configuration\\Project::getName() must match index name'); } parent::offsetSet($index, $newval); }
/** * @param InputInterface $input * @param OutputInterface $output * @param Project $project */ private function overrideSettings(InputInterface $input, OutputInterface $output, Project $project) { $branch = $input->getOption(self::OPTION_OVERRIDE_BRANCH); $name = null; if ($branch) { $output->writeln(sprintf('Overriding repository branch: <info>%s</info>… ', $branch)); $project->overrideBranch($branch); $name = preg_replace('#(/[^/]+)?$#', '/' . $branch, $project->getName()); } $name = $input->getOption(self::OPTION_OVERRIDE_NAME) ?: $name; if ($name) { $output->writeln(sprintf('Overriding project name: <info>%s</info>… ', $name)); $project->overrideName($name); $base = sprintf("%u", crc32($name)) % floor(1000 / sizeof($project->getFixedPorts())); $project->setFixedPortsBase(48000 + $base); } }