| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859 |
- <?php
- /**
- * pQuery plugin for executing common array functions.
- *
- * @package pQuery
- */
- /**
- * @todo Documentation
- */
- class pQueryArray extends pQuery implements pQueryExtension {
- function get($index) {
- return isset($this->variable[$index]) ? $this->variable[$index] : null;
- }
-
- function is_empty() {
- return !$this->count();
- }
-
- function reverse() {
- $this->variable = array_reverse($this->variable);
-
- return $this;
- }
-
- function __call($method, $args) {
- $function = 'array_'.$method;
-
- if( function_exists($function) ) {
- array_unshift($args, &$this->variable);
-
- return call_user_func_array($function, $args);
- }
-
- if( in_array($method, array('count')) )
- return $method($this->variable);
-
- if( in_array($method, array('shuffle')) ) {
- $method($this->variable);
- return $this;
- }
-
- return self::error('Plugin "%s" has no method "%s".', __CLASS__, $method);
- }
- }
- /**
- * Shortcut constructor for {@link pQuerySql}.
- *
- * @returns pQuerySql A new pQuerySql instance.
- * @see pQuerySql::__construct
- */
- function _arr($array) {
- return pQuery::create('array', $array);
- }
- pQuery::extend('pQueryArray', 'array');
- ?>
|