Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

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

… closes #24)
  • Loading branch information...
commit 5bd96492f13a09210b3f62a8c2c5179716033e2c 1 parent 89ae8de
Fabien Potencier authored
Showing with 19 additions and 0 deletions.
  1. +10 −0 lib/Pimple.php
  2. +9 −0 tests/Pimple/Tests/PimpleTest.php
10 lib/Pimple.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);
+ }
}
9 tests/Pimple/Tests/PimpleTest.php
View
@@ -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());
+ }
}
Please sign in to comment.
Something went wrong with that request. Please try again.