summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorEvan Prodromou <evan@prodromou.name>2008-05-29 11:23:04 -0400
committerEvan Prodromou <evan@prodromou.name>2008-05-29 11:23:04 -0400
commit22577b17edf1d901ed4f8a3089ed539d89e5f1e4 (patch)
tree1371a85e7e6caa78bf770c4b53d0be3ea62badd2 /lib
parentb153ac5b1b1f8849e1ba06d8c0f95eece855fa7b (diff)
even better boolean handling
darcs-hash:20080529152304-84dde-b0b0ea1f919701c2d821d9bf589a30db34dcc015.gz
Diffstat (limited to 'lib')
-rw-r--r--lib/action.php20
1 files changed, 11 insertions, 9 deletions
diff --git a/lib/action.php b/lib/action.php
index dae50e6e3..50370c09f 100644
--- a/lib/action.php
+++ b/lib/action.php
@@ -48,14 +48,16 @@ class Action { // lawsuit
}
function boolean($key, $def=false) {
- $arg = $this->arg($key);
- return (is_null($arg)) ? $def :
- (strcasecmp($arg, 'true') == 0) ? true :
- (strcasecmp($arg, 'yes') == 0) ? true :
- (strcasecmp($arg, '1') == 0) ? true :
- (strcasecmp($arg, 'false') == 0) ? false :
- (strcasecmp($arg, 'no') == 0) ? false :
- (strcasecmp($arg, '0') == 0) ? false :
- $def;
+ $arg = strtolower($this->trimmed($key));
+
+ if (is_null($arg)) {
+ return $def;
+ } else if (in_array($arg, array('true', 'yes', '1'))) {
+ return true;
+ } else if (in_array($arg, array('false', 'no', '0'))) {
+ return false;
+ } else {
+ return $def;
+ }
}
}