Skip to content

Commit b6b4c60

Browse files
committed
pool drop api
1 parent 39aa7c6 commit b6b4c60

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

src/Pool.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,13 @@ public function get($name)
4444
return $this->getMapper($name);
4545
}
4646

47+
public function drop($name)
48+
{
49+
if (array_key_exists($name, $this->mappers)) {
50+
unset($this->mappers[$name]);
51+
}
52+
}
53+
4754
public function getMapper($name)
4855
{
4956
if (array_key_exists($name, $this->mappers)) {

tests/PoolTest.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,11 @@ public function test()
1919
$pool->register('test2', $mapper2);
2020
$this->assertSame($pool->get('test2'), $mapper2);
2121
$this->assertNotSame($pool->get('test2'), $mapper);
22+
23+
$this->assertCount(2, $pool->getMappers());
24+
25+
$pool->drop('test');
26+
$this->assertCount(1, $pool->getMappers());
2227
}
2328

2429
public function testDynamic()

0 commit comments

Comments
 (0)