1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859 |
- <?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);
- }
- //abstract public function create(...$args);
- abstract public function search(array $params = array());
- }
- }
- ?>
|