projects
/
m6w6
/
seekat
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
|
github
raw
|
patch
|
inline
| side by side (parent:
a9e7d54
)
typeof
author
Michael Wallner
<mike@php.net>
Mon, 16 Jan 2017 08:34:34 +0000
(09:34 +0100)
committer
Michael Wallner
<mike@php.net>
Mon, 16 Jan 2017 08:34:34 +0000
(09:34 +0100)
lib/functions.php
patch
|
blob
|
history
diff --git
a/lib/functions.php
b/lib/functions.php
index 9e82d7200aef3ee44f6ca068bb29e6135f873874..9776da9b696f7c719b05b676c970c69e092e5fc0 100644
(file)
--- a/
lib/functions.php
+++ b/
lib/functions.php
@@
-1,7
+1,31
@@
<?php
<?php
+namespace seekat;
+
+/**
+ * Generate a human readable represenation of a variable
+ * @param mixed $arg
+ * @param bool $export whether to var_export the $arg
+ * @return string
+ */
+function typeof($arg, $export = false) {
+ $type = (is_object($arg)
+ ? "instance of ".get_class($arg)
+ : gettype($arg)
+ );
+ if ($export) {
+ $type .= ": ".var_export($arg, true);
+ }
+ return $type;
+}
+
namespace seekat\Exception;
namespace seekat\Exception;
+/**
+ * Canonicalize an error message from a string or Exception
+ * @param string|Exception $error
+ * @return string
+ */
function message(&$error) : string {
if ($error instanceof \Throwable) {
$message = $error->getMessage();
function message(&$error) : string {
if ($error instanceof \Throwable) {
$message = $error->getMessage();