/**
  * Removes a target from the collection.
  *
  * If the target does not exist, this method does nothing.
  *
  * @param string $targetName The target name.
  */
 public function remove($targetName)
 {
     if (InstallTarget::DEFAULT_TARGET === $targetName && $this->defaultTarget) {
         $targetName = $this->defaultTarget->getName();
     }
     unset($this->targets[$targetName]);
     if ($this->defaultTarget && $targetName === $this->defaultTarget->getName()) {
         $this->defaultTarget = $this->targets ? reset($this->targets) : null;
     }
 }
Example #2
0
 public function testCreate()
 {
     $target = new InstallTarget('local', 'symlink', 'web/assets', '/assets/%s');
     $this->assertSame('local', $target->getName());
     $this->assertSame('symlink', $target->getInstallerName());
     $this->assertSame('web/assets', $target->getLocation());
     $this->assertSame('/assets/%s', $target->getUrlFormat());
     $this->assertSame(array(), $target->getParameterValues());
 }
 private function targetsEqual(InstallTarget $target1, InstallTarget $target2)
 {
     if ($target1->getName() !== $target2->getName()) {
         return false;
     }
     if ($target1->getInstallerName() !== $target2->getInstallerName()) {
         return false;
     }
     if ($target1->getLocation() !== $target2->getLocation()) {
         return false;
     }
     if ($target1->getUrlFormat() !== $target2->getUrlFormat()) {
         return false;
     }
     $parameters1 = $target1->getParameterValues();
     $parameters2 = $target2->getParameterValues();
     ksort($parameters1);
     ksort($parameters2);
     if ($parameters1 !== $parameters2) {
         return false;
     }
     return true;
 }