Fixes the function that returns int in PlDict, adds count and merge to PlDict.
authorStéphane Jacob <sj@m4x.org>
Sun, 28 Feb 2010 13:17:44 +0000 (14:17 +0100)
committerStéphane Jacob <sj@m4x.org>
Sun, 28 Feb 2010 16:15:00 +0000 (17:15 +0100)
Signed-off-by: Stéphane Jacob <sj@m4x.org>
classes/pldict.php

index a704cff..b67095a 100644 (file)
@@ -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: