Skip to content

Commit 751e491

Browse files
committed
Added cleanArgs method to Definition
1 parent b4a6217 commit 751e491

2 files changed

Lines changed: 33 additions & 0 deletions

File tree

src/League/Di/Definition.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,18 @@ public function addArgs(array $args)
122122
return $this;
123123
}
124124

125+
/**
126+
* Remove all available arguments
127+
*
128+
* @return Definition
129+
*/
130+
public function cleanArgs()
131+
{
132+
$this->arguments = array();
133+
134+
return $this;
135+
}
136+
125137
/**
126138
* Adds a method call to be executed after instantiating.
127139
*

test/League/Di/Test/DefinitionTest.php

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,27 @@ public function testAddArgs()
224224
);
225225
}
226226

227+
/**
228+
* Tests removing arguments from a Defintion.
229+
*
230+
* @return void
231+
*/
232+
public function testCleanArgs()
233+
{
234+
$definition = new Definition($this->container, 'League\\Di\\Stub\\Foo');
235+
236+
$definition->addArgs(array('foo', 'bar'));
237+
238+
$definition->cleanArgs();
239+
240+
$this->assertAttributeEquals(
241+
array(),
242+
'arguments',
243+
$definition,
244+
'All arguments should be removed from the arguments array.'
245+
);
246+
}
247+
227248
public function testWithMethod()
228249
{
229250
$definition = new Definition($this->container, 'League\\Di\\Stub\\Qux');

0 commit comments

Comments
 (0)