Permalink
Browse files

Docs

  • Loading branch information...
1 parent 38f1ef6 commit 4bc93a3fb214b2f989d5610e40a943862608c963 @kakserpom committed Mar 19, 2013
Showing with 41 additions and 0 deletions.
  1. +23 −0 lib/ObjectStorage.php
  2. +18 −0 lib/StackCallbacks.php
View
@@ -1,5 +1,12 @@
<?php
class ObjectStorage extends SplObjectStorage {
+
+ /**
+ * Call given method of all objects in storage
+ * @param string Method
+ * @param ... arguments ...
+ * @return integer Number of called objects
+ */
public function each() {
if ($this->count() === 0) {
return 0;
@@ -13,12 +20,23 @@ public function each() {
}
return $n;
}
+
+ /**
+ * Remove all objects from this storage, which contained in another storage
+ * @param SplObjectStorage
+ * @return void
+ */
public function removeAll($obj = null) {
if ($obj === null) {
$this->removeAllExcept(new SplObjectStorage);
}
parent::removeAll($obj);
}
+
+ /**
+ * Detaches first object and returns it
+ * @return object
+ */
public function detachFirst() {
$this->rewind();
$o = $this->current();
@@ -28,6 +46,11 @@ public function detachFirst() {
$this->detach($o);
return $o;
}
+
+ /**
+ * Returns first object
+ * @return object
+ */
public function getFirst() {
$this->rewind();
return $this->current();
View
@@ -1,11 +1,25 @@
<?php
class StackCallbacks extends SplStack {
+ /**
+ * Push callback to the bottom of stack
+ * @param callable Callback
+ * @return void
+ */
public function push($cb) {
parent::push(CallbackWrapper::wrap($cb));
}
+
+ /* Push callback to the top of stack
+ * @param callable Callback
+ * @return void
+ */
public function unshift($cb) {
parent::unshift(CallbackWrapper::wrap($cb));
}
+
+ /* Executes one callback from the top with given arguments.
+ * @return void
+ */
public function executeOne() {
if ($this->isEmpty()) {
return false;
@@ -16,6 +30,10 @@ public function executeOne() {
}
return true;
}
+
+ /* Executes all callbacks with given arguments.
+ * @return void
+ */
public function executeAll() {
if ($this->isEmpty()) {
return 0;

0 comments on commit 4bc93a3

Please sign in to comment.