/** * Removes a constant * * @param string|PhpConstant $nameOrConstant constant name * @throws \InvalidArgumentException If the constant cannot be found * @return $this */ public function removeConstant($nameOrConstant) { if ($nameOrConstant instanceof PhpConstant) { $nameOrConstant = $nameOrConstant->getName(); } if (!$this->constants->has($nameOrConstant)) { throw new \InvalidArgumentException(sprintf('The constant "%s" does not exist.', $nameOrConstant)); } $this->constants->remove($nameOrConstant); return $this; }
/** * Removes a property * * @param PhpProperty|string $nameOrProperty property name or instance * @throws \InvalidArgumentException If the property cannot be found * @return $this */ public function removeProperty($nameOrProperty) { if ($nameOrProperty instanceof PhpProperty) { $nameOrProperty = $nameOrProperty->getName(); } if (!$this->properties->has($nameOrProperty)) { throw new \InvalidArgumentException(sprintf('The property "%s" does not exist.', $nameOrProperty)); } $p = $this->properties->get($nameOrProperty); $p->setParent(null); $this->properties->remove($nameOrProperty); return $this; }
/** * Removes a method * * @param string|PhpMethod $nameOrMethod method name or Method instance * @throws \InvalidArgumentException if the method cannot be found * @return $this */ public function removeMethod($nameOrMethod) { if ($nameOrMethod instanceof PhpMethod) { $nameOrMethod = $nameOrMethod->getName(); } if (!$this->methods->has($nameOrMethod)) { throw new \InvalidArgumentException(sprintf('The method "%s" does not exist.', $nameOrMethod)); } $m = $this->methods->get($nameOrMethod); $m->setParent(null); $this->methods->remove($nameOrMethod); return $this; }
public function testAddGetRemove() { $key1 = 'key1'; $key2 = 'key2'; $key3 = 'key3'; $item1 = 'item 1'; $item2 = 'item 2'; $item3 = 'item 3'; $items = [$key1 => $item1, $key2 => $item2]; $keys = new Set([$key1, $key2]); $values = new ArrayList([$item1, $item2]); $map = new Map(); $map->set($key1, $item1); $this->assertEquals(1, $map->size()); $this->assertEquals($item1, $map->get($key1)); $this->assertTrue($map->has($key1)); $this->assertFalse($map->has($key2)); $map->remove($key1); $this->assertEquals(0, $map->size()); $map->setAll($items); $this->assertEquals(2, $map->size()); $this->assertEquals($keys, $map->keys()); $this->assertEquals($values, $map->values()); $map->set($key3, $item3); $this->assertEquals(3, $map->size()); $map->clear(); $this->assertEquals(0, $map->size()); $dupKeyItems = [$key1 => $item1, $key2 => $item2]; $map->setAll($dupKeyItems); $map->set($key2, $item3); $this->assertEquals(2, $map->size()); $this->assertEquals($item3, $map->get($key2)); $this->assertEmpty($map->get('non_existing_key')); $this->assertEmpty($map->remove('non_existing_key')); $this->assertEquals([], $map->get('non_existing_key', [])); }
/** * Removes the given security * * @param string $id */ public function remove($id) { $this->securities->remove($id); return $this; }
public function moduleDeactivated(ModuleEvent $e) { $module = $e->getModule(); $this->activatedModules->remove($module->getName()); }
/** * Removes the given header * * @param string $header */ public function remove($header) { $this->headers->remove($header); }
/** * Removes the given field * * @param string $name */ public function remove($name) { $this->definitions->remove($name); }
/** * Removes the given scheme * * @param string $scheme */ public function remove($scheme) { $this->schemes->remove($scheme); return $this; }
public function testTextAsKey() { $map = new Map(); $key = new Text('k'); $map->set($key, 'val'); $this->assertTrue($map->has($key)); $this->assertEquals('val', $map->get($key)); $map->remove($key); $this->assertEquals(0, $map->size()); }
/** * Removes the given path * * @param string $path */ public function remove($path) { $this->paths->remove($path); return $this; }
/** * Removes the given repsonse * * @param string $code */ public function remove($code) { $this->responses->remove($code); }