static function kind($path) { $k = filetype($path); switch ($k) { case "file": return php_FileKind::$kfile; break; case "dir": return php_FileKind::$kdir; break; default: return php_FileKind::kother($k); break; } }
<?php class php_FileKind extends Enum { public static $kdir; public static $kfile; public static function kother($k) { return new php_FileKind("kother", 2, array($k)); } } php_FileKind::$kdir = new php_FileKind("kdir", 0); php_FileKind::$kfile = new php_FileKind("kfile", 1);