Permalink
Browse files

added a keys() method that returns all defined value names (closes #36,…

… closes #24)
  • Loading branch information...
1 parent 89ae8de commit 5bd96492f13a09210b3f62a8c2c5179716033e2c @fabpot committed Jun 9, 2012
Showing with 19 additions and 0 deletions.
  1. +10 −0 lib/Pimple.php
  2. +9 −0 tests/Pimple/Tests/PimpleTest.php
View
@@ -187,4 +187,14 @@ function extend($id, Closure $callable)
return $callable($factory($c), $c);
};
}
+
+ /**
+ * Returns all defined value names.
+ *
+ * @return array An array of value names
+ */
+ function keys()
+ {
+ return array_keys($this->values);
+ }
}
@@ -236,4 +236,13 @@ public function testExtendValidatesKeyYieldsObjectDefinition()
$pimple['foo'] = 123;
$pimple->extend('foo', function () {});
}
+
+ public function testKeys()
+ {
+ $pimple = new Pimple();
+ $pimple['foo'] = 123;
+ $pimple['bar'] = 123;
+
+ $this->assertEquals(array('foo', 'bar'), $pimple->keys());
+ }
}

0 comments on commit 5bd9649

Please sign in to comment.