From: Stéphane Jacob Date: Sun, 28 Feb 2010 13:17:44 +0000 (+0100) Subject: Fixes the function that returns int in PlDict, adds count and merge to PlDict. X-Git-Tag: core/1.1.0~69 X-Git-Url: http://git.polytechnique.org/?a=commitdiff_plain;h=42522e2123d8092f2351bf03086024e6b6bb6ba8;p=platal.git Fixes the function that returns int in PlDict, adds count and merge to PlDict. Signed-off-by: Stéphane Jacob --- diff --git a/classes/pldict.php b/classes/pldict.php index a704cff..b67095a 100644 --- a/classes/pldict.php +++ b/classes/pldict.php @@ -80,7 +80,7 @@ class PlDict public function i($key, $default = 0) { $i = $this->_get($key, $default); - return ctype_digit($i) ? intval($i) : $default; + return (is_int($i) || ctype_digit($i)) ? intval($i) : $default; } public function l(array $keys) @@ -92,6 +92,16 @@ class PlDict { return $this->array; } + + public function count() + { + return count($this->array); + } + + public function merge(array $array) + { + $this->array = array_merge($this->array, $array); + } } // vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8: