diff --git a/src/Intervention/Image/Commands/Argument.php b/src/Intervention/Image/Commands/Argument.php index 15f083fe..552e30e1 100644 --- a/src/Intervention/Image/Commands/Argument.php +++ b/src/Intervention/Image/Commands/Argument.php @@ -113,6 +113,11 @@ class Argument $message = sprintf('%s accepts only string values as argument %d.', $this->getCommandName(), $this->key + 1); break; + case 'array': + $fail = ! is_array($value); + $message = sprintf('%s accepts only array as argument %d.', $this->getCommandName(), $this->key + 1); + break; + case 'closure': $fail = ! is_a($value, '\Closure'); $message = sprintf('%s accepts only Closure as argument %d.', $this->getCommandName(), $this->key + 1); diff --git a/tests/ArgumentTest.php b/tests/ArgumentTest.php index 6c212f21..1a187c4e 100644 --- a/tests/ArgumentTest.php +++ b/tests/ArgumentTest.php @@ -69,6 +69,26 @@ class ArgumentTest extends PHPUnit_Framework_TestCase $arg->type('integer'); } + public function testTypeArrayPass() + { + $arg = new Argument($this->getMockedCommand(array())); + $arg->type('array'); + $this->validateArgument($arg, null); + + $arg = new Argument($this->getMockedCommand(array(array(1,2,3)))); + $arg->type('array'); + $this->validateArgument($arg, array(1,2,3)); + } + + /** + * @expectedException \Intervention\Image\Exception\InvalidArgumentException + */ + public function testTypeArrayFail() + { + $arg = new Argument($this->getMockedCommand(array('foo'))); + $arg->type('array'); + } + public function testTypeDigitPass() { $arg = new Argument($this->getMockedCommand(array()));