X-Git-Url: https://git.m6w6.name/?a=blobdiff_plain;f=lib%2Ffunctions.php;h=8a1615be160d1cf9b9bc3037056b1296e120601e;hb=654d736df2c46ec2520f73e9089d06a44f2b9c50;hp=fdd9ea0a02bf16a0079b8782c065f3b53063390d;hpb=f4aa6beaf2e1f0dc9c877782cbbad5a989194517;p=m6w6%2Fseekat diff --git a/lib/functions.php b/lib/functions.php index fdd9ea0..8a1615b 100644 --- a/lib/functions.php +++ b/lib/functions.php @@ -1,21 +1,28 @@ expand($str, $arr); + } } - return $type; } +namespace seekat { + /** + * Generate a human-readable representation of a variable + * @param mixed $arg + * @param bool $export whether to var_export the $arg + * @return string + */ + function typeof($arg, bool $export = false) : string { + $type = is_object($arg) + ? "instance of ".get_class($arg) + : gettype($arg); + if ($export) { + $type .= ": ".var_export($arg, true); + } + return $type; + } +}