/** * Check type exists * * @param string $pattern * @return bool */ public static function typeExists(string $pattern) : bool { $typeProvider = new TypeProvider(); if (isset($typeProvider->listTypes()[$pattern])) { return true; } return false; }
public function testtypeTypeValue() { $this->assertEquals('integer', TypeProvider::type(1)); $this->assertEquals('string', TypeProvider::type('1')); $this->assertEquals('array', TypeProvider::type(array('1', 0))); $this->assertEquals('object', TypeProvider::type(new \stdClass())); $this->assertEquals('boolean', TypeProvider::type(true)); }
/** * Return type of value * * @param $value * @return string */ public function type($value) : string { return TypeProvider::type($value); }