Skip to content

Commit

Permalink
Add isTypeArray()
Browse files Browse the repository at this point in the history
  • Loading branch information
eduardosoliv committed Jan 25, 2014
1 parent 979da86 commit c876bf0
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/EBT/Validator/ValidatorBasicExtended.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,17 @@ public static function isTypeBool($value, array $options = array())
return static::isType($value, 'bool', $options);
}

/**
* @param mixed $value
* @param array $options
*
* @return bool
*/
public static function isTypeArray($value, array $options = array())
{
return static::isType($value, 'array', $options);
}

/**
* Uses the Type constraint of Symfony, the name of the method is not isTypeNumeric, because numeric is not a type.
*
Expand Down
11 changes: 11 additions & 0 deletions tests/EBT/Validator/Tests/ValidatorBasicExtendedTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,17 @@ public function testIsTypeBool()
$this->assertTrue(ValidatorBasicExtended::isTypeBool(false));
}

public function testIsTypeArray()
{
$this->assertFalse(ValidatorBasicExtended::isTypeArray(10));
$this->assertFalse(ValidatorBasicExtended::isTypeArray(10.5));
$this->assertFalse(ValidatorBasicExtended::isTypeArray('test'));
$this->assertFalse(ValidatorBasicExtended::isTypeArray(false));
$this->assertTrue(ValidatorBasicExtended::isTypeArray(array()));
$this->assertTrue(ValidatorBasicExtended::isTypeArray(array(1)));
$this->assertTrue(ValidatorBasicExtended::isTypeArray(array('test', 'and test')));
}

public function testIsNumeric()
{
$this->assertTrue(ValidatorBasicExtended::isNumeric(10.5));
Expand Down

0 comments on commit c876bf0

Please sign in to comment.