public function testRemoveIgnoresNonExisting() { $this->collection->add($this->server1); $this->collection->add($this->server2); $this->collection->remove('foobar'); $this->assertSame(array('server1' => $this->server1, 'server2' => $this->server2), $this->collection->toArray()); }
/** * {@inheritdoc} */ public function removeServers(Expression $expr) { $this->assertServersLoaded(); $previousServers = $this->servers->toArray(); $previousData = $this->serversData; $save = false; foreach ($this->servers as $server) { if ($server->match($expr)) { $this->servers->remove($server->getName()); unset($this->serversData[$server->getName()]); $save = true; } } if (!$save) { return; } try { $this->persistServersData(); } catch (Exception $e) { $this->servers->replace($previousServers); $this->serversData = $previousData; throw $e; } }