12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364 |
- <?php
- namespace Gogs\API\Request {
- abstract class Collection extends Base implements \Gogs\Lib\ArrayIterator {
- private $objs = array();
- public function add($obj, $key = null) {
- if (!isset($key))
- array_push($this->objs, $obj);
- else
- $this->objs[$key] = $obj;
- }
- public function remove($any) {
- if (isset($this->objs[$any])) {
- unset($this->objs[$any]);
- return true;
- } else if (in_array($any, $this->objs)) {
- $key = array_search($any, $this->objs, true);
- return $this->remove($key);
- }
- return false;
- }
- public function all() {
- return $this->objs;
- }
- public function len() {
- return count($this->objs);
- }
- public function by_key($idx) {
- return isset($this->objs[$idx]) ? $this->objs[$idx] : false;
- }
- public function next() {
- return next($this->objs);
- }
- public function prev() {
- return prev($this->objs);
- }
- public function current() {
- return current($this->objs);
- }
- public function reset() {
- return reset($this->objs);
- }
- /**
- * Search for an object.
- *
- * @param array $params Parameters
- * @return Gogs\Lib\Collection
- */
- abstract public function search(array $params = array());
- }
- }
- ?>
|