='); } /** * Import * * @param string $path * * @return bool */ public static function import(string $path) : bool { return in_array( realpath(Base::suffix($path, '.php')), get_required_files() ); } /** * URL * * @param string $url * * @return bool */ public static function url(string $url) : bool { return preg_match('#^(\w+:)?//#i', $url); } /** * Email * * @param string $email * * @return bool */ public static function email(string $email) : bool { return preg_match("/^([a-z0-9\+_\-]+)(\.[a-z0-9\+_\-]+)*@([a-z0-9\-]+\.)+[a-z]{2,6}$/ix", $email); } /** * Char * * @param mixed $str * * @return bool */ public static function char($str) : bool { return is_scalar($str); } /** * Real Numeric * * @param mixed $num = 0 * * @return bool */ public static function realNumeric($num = 0) : bool { return ! is_string($num) && is_numeric($num); } /** * Declared Class * * @param string $class * * @return bool */ public static function declaredClass(string $class) : bool { return in_array(strtolower($class), array_map('strtolower', get_declared_classes())); } /** * Hash * * @param string $type * * @return bool */ public static function hash(string $type) : bool { $hashAlgos = array_merge(hash_algos(), ['super', 'golden']); return in_array($type, $hashAlgos); } /** * Charset * * @param string $charset * * @return bool */ public static function charset(string $charset) : bool { return array_search(strtolower($charset), array_map('strtolower', mb_list_encodings()), true); } /** * Array * * @param mixed $array * * @return bool */ public static function array($array) : bool { return ! empty($array) && is_array($array); } /** * Slug * * @param string $slug * * @return bool */ public static function slug(string $slug) : bool { return (bool) preg_match('/^([a-z0-9]+\-*){1,}$/', $slug); } /** * Closure * * @param mixed $data * * @return bool */ public static function closure($data) : bool { return ! is_string($data) && is_callable($data); } }