isNumeric() public static method

Checks to see if all the values in the array are numeric.
public static isNumeric ( array $array = null ) : mixed
$array array The array to check. If null, the value of the current Set object.
return mixed `true` if values are numeric, `false` if not and `null` if the array to check is empty.
Example #1
0
	public function testIsNumericArrayCheck() {
		$data = array('one');
		$this->assertTrue(Set::isNumeric(array_keys($data)));

		$data = array(1 => 'one');
		$this->assertFalse(Set::isNumeric($data));

		$data = array('one');
		$this->assertFalse(Set::isNumeric($data));

		$data = array('one' => 'two');
		$this->assertFalse(Set::isNumeric($data));

		$data = array('one' => 1);
		$this->assertTrue(Set::isNumeric($data));

		$data = array(0);
		$this->assertTrue(Set::isNumeric($data));

		$data = array('one', 'two', 'three', 'four', 'five');
		$this->assertTrue(Set::isNumeric(array_keys($data)));

		$data = array(1 => 'one', 2 => 'two', 3 => 'three', 4 => 'four', 5 => 'five');
		$this->assertTrue(Set::isNumeric(array_keys($data)));

		$data = array('1' => 'one', 2 => 'two', 3 => 'three', 4 => 'four', 5 => 'five');
		$this->assertTrue(Set::isNumeric(array_keys($data)));

		$data = array('one', 2 => 'two', 3 => 'three', 4 => 'four', 'a' => 'five');
		$this->assertFalse(Set::isNumeric(array_keys($data)));

		$data = array();
		$this->assertNull(Set::isNumeric($data));
	}