diff --git a/.travis.yml b/.travis.yml
index c791578..700f59a 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -15,4 +15,9 @@ matrix:
before_script:
- composer install --dev
-script: phpunit --coverage-text
\ No newline at end of file
+script:
+ - mkdir -p build/logs
+ - php vendor/bin/phpunit -c phpunit.xml.dist
+
+after_success:
+ - travis_retry php vendor/bin/coveralls -v
\ No newline at end of file
diff --git a/README.md b/README.md
index f20f4c2..ec2a2c2 100644
--- a/README.md
+++ b/README.md
@@ -1,4 +1,5 @@
-# ArrayObjectArray [![Build Status](https://travis-ci.org/sikofitt/array-object-array.svg?branch=master)](https://travis-ci.org/sikofitt/array-object-array)
+# ArrayObjectArray [![Build Status](https://travis-ci.org/sikofitt/array-object-array.svg?branch=master)](https://travis-ci.org/sikofitt/array-object-array) [![Coverage Status](https://coveralls.io/repos/github/sikofitt/array-object-array/badge.svg?branch=master)](https://coveralls.io/github/sikofitt/array-object-array?branch=master)
+
This is an incredibly simple class extension of `\ArrayObject` to provide
array functions use the magic `__call` method. I no longer like writing this
diff --git a/composer.json b/composer.json
index bca3419..f71e01d 100644
--- a/composer.json
+++ b/composer.json
@@ -1,22 +1,26 @@
{
"name": "sikofitt/array-object-array",
"description": "ArrayObject class that implements array functions through __call",
+ "keywords": ["array", "object", "php", "magic", "call"],
"type": "library",
"require": {
- "php": ">=5.3.29",
+ "php": ">=5.3",
"symfony/polyfill-php54": "^1.2",
"symfony/polyfill-php55": "^1.2",
"symfony/polyfill-php56": "^1.2"
},
"require-dev": {
- "phpunit/phpunit": "*",
- "phpunit/php-code-coverage": "*"
+ "phpunit/phpunit": "~4.8",
+ "phpunit/php-code-coverage": "~2.2",
+ "satooshi/php-coveralls": "^1.0"
},
"license": "MIT",
"authors": [
{
"name": "sikofitt",
- "email": "sikofitt@gmail.com"
+ "email": "sikofitt@gmail.com",
+ "homepage": "http://rewiv.com",
+ "role": "developer"
}
],
"autoload": {
diff --git a/composer.lock b/composer.lock
index 9215bea..8ed9faa 100644
--- a/composer.lock
+++ b/composer.lock
@@ -4,8 +4,8 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
"This file is @generated automatically"
],
- "hash": "5da3f055fabd5e44bb25a547d0aea8de",
- "content-hash": "623968123c52d5ef08b66b52671f3c04",
+ "hash": "e783c69d217d2ee4cd8d84375554030d",
+ "content-hash": "a03a3e83bc124fad42d5a75c770dc38a",
"packages": [
{
"name": "ircmaxell/password-compat",
@@ -327,6 +327,102 @@
],
"time": "2015-06-14 21:17:01"
},
+ {
+ "name": "guzzle/guzzle",
+ "version": "v3.9.3",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/guzzle/guzzle3.git",
+ "reference": "0645b70d953bc1c067bbc8d5bc53194706b628d9"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/guzzle/guzzle3/zipball/0645b70d953bc1c067bbc8d5bc53194706b628d9",
+ "reference": "0645b70d953bc1c067bbc8d5bc53194706b628d9",
+ "shasum": ""
+ },
+ "require": {
+ "ext-curl": "*",
+ "php": ">=5.3.3",
+ "symfony/event-dispatcher": "~2.1"
+ },
+ "replace": {
+ "guzzle/batch": "self.version",
+ "guzzle/cache": "self.version",
+ "guzzle/common": "self.version",
+ "guzzle/http": "self.version",
+ "guzzle/inflection": "self.version",
+ "guzzle/iterator": "self.version",
+ "guzzle/log": "self.version",
+ "guzzle/parser": "self.version",
+ "guzzle/plugin": "self.version",
+ "guzzle/plugin-async": "self.version",
+ "guzzle/plugin-backoff": "self.version",
+ "guzzle/plugin-cache": "self.version",
+ "guzzle/plugin-cookie": "self.version",
+ "guzzle/plugin-curlauth": "self.version",
+ "guzzle/plugin-error-response": "self.version",
+ "guzzle/plugin-history": "self.version",
+ "guzzle/plugin-log": "self.version",
+ "guzzle/plugin-md5": "self.version",
+ "guzzle/plugin-mock": "self.version",
+ "guzzle/plugin-oauth": "self.version",
+ "guzzle/service": "self.version",
+ "guzzle/stream": "self.version"
+ },
+ "require-dev": {
+ "doctrine/cache": "~1.3",
+ "monolog/monolog": "~1.0",
+ "phpunit/phpunit": "3.7.*",
+ "psr/log": "~1.0",
+ "symfony/class-loader": "~2.1",
+ "zendframework/zend-cache": "2.*,<2.3",
+ "zendframework/zend-log": "2.*,<2.3"
+ },
+ "suggest": {
+ "guzzlehttp/guzzle": "Guzzle 5 has moved to a new package name. The package you have installed, Guzzle 3, is deprecated."
+ },
+ "type": "library",
+ "extra": {
+ "branch-alias": {
+ "dev-master": "3.9-dev"
+ }
+ },
+ "autoload": {
+ "psr-0": {
+ "Guzzle": "src/",
+ "Guzzle\\Tests": "tests/"
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "Michael Dowling",
+ "email": "mtdowling@gmail.com",
+ "homepage": "https://github.com/mtdowling"
+ },
+ {
+ "name": "Guzzle Community",
+ "homepage": "https://github.com/guzzle/guzzle/contributors"
+ }
+ ],
+ "description": "PHP HTTP client. This library is deprecated in favor of https://packagist.org/packages/guzzlehttp/guzzle",
+ "homepage": "http://guzzlephp.org/",
+ "keywords": [
+ "client",
+ "curl",
+ "framework",
+ "http",
+ "http client",
+ "rest",
+ "web service"
+ ],
+ "abandoned": "guzzlehttp/guzzle",
+ "time": "2015-03-18 18:23:50"
+ },
{
"name": "phpdocumentor/reflection-docblock",
"version": "2.0.4",
@@ -683,16 +779,16 @@
},
{
"name": "phpunit/phpunit",
- "version": "4.8.26",
+ "version": "4.8.27",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/phpunit.git",
- "reference": "fc1d8cd5b5de11625979125c5639347896ac2c74"
+ "reference": "c062dddcb68e44b563f66ee319ddae2b5a322a90"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/fc1d8cd5b5de11625979125c5639347896ac2c74",
- "reference": "fc1d8cd5b5de11625979125c5639347896ac2c74",
+ "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/c062dddcb68e44b563f66ee319ddae2b5a322a90",
+ "reference": "c062dddcb68e44b563f66ee319ddae2b5a322a90",
"shasum": ""
},
"require": {
@@ -751,7 +847,7 @@
"testing",
"xunit"
],
- "time": "2016-05-17 03:09:28"
+ "time": "2016-07-21 06:48:14"
},
{
"name": "phpunit/phpunit-mock-objects",
@@ -809,6 +905,102 @@
],
"time": "2015-10-02 06:51:40"
},
+ {
+ "name": "psr/log",
+ "version": "1.0.0",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/php-fig/log.git",
+ "reference": "fe0936ee26643249e916849d48e3a51d5f5e278b"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/php-fig/log/zipball/fe0936ee26643249e916849d48e3a51d5f5e278b",
+ "reference": "fe0936ee26643249e916849d48e3a51d5f5e278b",
+ "shasum": ""
+ },
+ "type": "library",
+ "autoload": {
+ "psr-0": {
+ "Psr\\Log\\": ""
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "PHP-FIG",
+ "homepage": "http://www.php-fig.org/"
+ }
+ ],
+ "description": "Common interface for logging libraries",
+ "keywords": [
+ "log",
+ "psr",
+ "psr-3"
+ ],
+ "time": "2012-12-21 11:40:51"
+ },
+ {
+ "name": "satooshi/php-coveralls",
+ "version": "v1.0.1",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/satooshi/php-coveralls.git",
+ "reference": "da51d304fe8622bf9a6da39a8446e7afd432115c"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/satooshi/php-coveralls/zipball/da51d304fe8622bf9a6da39a8446e7afd432115c",
+ "reference": "da51d304fe8622bf9a6da39a8446e7afd432115c",
+ "shasum": ""
+ },
+ "require": {
+ "ext-json": "*",
+ "ext-simplexml": "*",
+ "guzzle/guzzle": "^2.8|^3.0",
+ "php": ">=5.3.3",
+ "psr/log": "^1.0",
+ "symfony/config": "^2.1|^3.0",
+ "symfony/console": "^2.1|^3.0",
+ "symfony/stopwatch": "^2.0|^3.0",
+ "symfony/yaml": "^2.0|^3.0"
+ },
+ "suggest": {
+ "symfony/http-kernel": "Allows Symfony integration"
+ },
+ "bin": [
+ "bin/coveralls"
+ ],
+ "type": "library",
+ "autoload": {
+ "psr-4": {
+ "Satooshi\\": "src/Satooshi/"
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "Kitamura Satoshi",
+ "email": "with.no.parachute@gmail.com",
+ "homepage": "https://www.facebook.com/satooshi.jp"
+ }
+ ],
+ "description": "PHP client library for Coveralls API",
+ "homepage": "https://github.com/satooshi/php-coveralls",
+ "keywords": [
+ "ci",
+ "coverage",
+ "github",
+ "test"
+ ],
+ "time": "2016-01-20 17:35:46"
+ },
{
"name": "sebastian/comparator",
"version": "1.2.0",
@@ -1181,6 +1373,336 @@
"homepage": "https://github.com/sebastianbergmann/version",
"time": "2015-06-21 13:59:46"
},
+ {
+ "name": "symfony/config",
+ "version": "v2.8.8",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/symfony/config.git",
+ "reference": "0926e69411eba491803dbafb9f1f233e2ced58d0"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/symfony/config/zipball/0926e69411eba491803dbafb9f1f233e2ced58d0",
+ "reference": "0926e69411eba491803dbafb9f1f233e2ced58d0",
+ "shasum": ""
+ },
+ "require": {
+ "php": ">=5.3.9",
+ "symfony/filesystem": "~2.3|~3.0.0"
+ },
+ "suggest": {
+ "symfony/yaml": "To use the yaml reference dumper"
+ },
+ "type": "library",
+ "extra": {
+ "branch-alias": {
+ "dev-master": "2.8-dev"
+ }
+ },
+ "autoload": {
+ "psr-4": {
+ "Symfony\\Component\\Config\\": ""
+ },
+ "exclude-from-classmap": [
+ "/Tests/"
+ ]
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "Fabien Potencier",
+ "email": "fabien@symfony.com"
+ },
+ {
+ "name": "Symfony Community",
+ "homepage": "https://symfony.com/contributors"
+ }
+ ],
+ "description": "Symfony Config Component",
+ "homepage": "https://symfony.com",
+ "time": "2016-06-29 05:31:50"
+ },
+ {
+ "name": "symfony/console",
+ "version": "v2.8.8",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/symfony/console.git",
+ "reference": "c392a6ec72f2122748032c2ad6870420561ffcfa"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/symfony/console/zipball/c392a6ec72f2122748032c2ad6870420561ffcfa",
+ "reference": "c392a6ec72f2122748032c2ad6870420561ffcfa",
+ "shasum": ""
+ },
+ "require": {
+ "php": ">=5.3.9",
+ "symfony/polyfill-mbstring": "~1.0"
+ },
+ "require-dev": {
+ "psr/log": "~1.0",
+ "symfony/event-dispatcher": "~2.1|~3.0.0",
+ "symfony/process": "~2.1|~3.0.0"
+ },
+ "suggest": {
+ "psr/log": "For using the console logger",
+ "symfony/event-dispatcher": "",
+ "symfony/process": ""
+ },
+ "type": "library",
+ "extra": {
+ "branch-alias": {
+ "dev-master": "2.8-dev"
+ }
+ },
+ "autoload": {
+ "psr-4": {
+ "Symfony\\Component\\Console\\": ""
+ },
+ "exclude-from-classmap": [
+ "/Tests/"
+ ]
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "Fabien Potencier",
+ "email": "fabien@symfony.com"
+ },
+ {
+ "name": "Symfony Community",
+ "homepage": "https://symfony.com/contributors"
+ }
+ ],
+ "description": "Symfony Console Component",
+ "homepage": "https://symfony.com",
+ "time": "2016-06-29 07:02:14"
+ },
+ {
+ "name": "symfony/event-dispatcher",
+ "version": "v2.8.8",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/symfony/event-dispatcher.git",
+ "reference": "b180b70439dca70049b6b9b7e21d75e6e5d7aca9"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/b180b70439dca70049b6b9b7e21d75e6e5d7aca9",
+ "reference": "b180b70439dca70049b6b9b7e21d75e6e5d7aca9",
+ "shasum": ""
+ },
+ "require": {
+ "php": ">=5.3.9"
+ },
+ "require-dev": {
+ "psr/log": "~1.0",
+ "symfony/config": "~2.0,>=2.0.5|~3.0.0",
+ "symfony/dependency-injection": "~2.6|~3.0.0",
+ "symfony/expression-language": "~2.6|~3.0.0",
+ "symfony/stopwatch": "~2.3|~3.0.0"
+ },
+ "suggest": {
+ "symfony/dependency-injection": "",
+ "symfony/http-kernel": ""
+ },
+ "type": "library",
+ "extra": {
+ "branch-alias": {
+ "dev-master": "2.8-dev"
+ }
+ },
+ "autoload": {
+ "psr-4": {
+ "Symfony\\Component\\EventDispatcher\\": ""
+ },
+ "exclude-from-classmap": [
+ "/Tests/"
+ ]
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "Fabien Potencier",
+ "email": "fabien@symfony.com"
+ },
+ {
+ "name": "Symfony Community",
+ "homepage": "https://symfony.com/contributors"
+ }
+ ],
+ "description": "Symfony EventDispatcher Component",
+ "homepage": "https://symfony.com",
+ "time": "2016-06-29 05:29:29"
+ },
+ {
+ "name": "symfony/filesystem",
+ "version": "v2.8.8",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/symfony/filesystem.git",
+ "reference": "7258ddd6f987053f21fa43d03430580ba54e6096"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/symfony/filesystem/zipball/7258ddd6f987053f21fa43d03430580ba54e6096",
+ "reference": "7258ddd6f987053f21fa43d03430580ba54e6096",
+ "shasum": ""
+ },
+ "require": {
+ "php": ">=5.3.9"
+ },
+ "type": "library",
+ "extra": {
+ "branch-alias": {
+ "dev-master": "2.8-dev"
+ }
+ },
+ "autoload": {
+ "psr-4": {
+ "Symfony\\Component\\Filesystem\\": ""
+ },
+ "exclude-from-classmap": [
+ "/Tests/"
+ ]
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "Fabien Potencier",
+ "email": "fabien@symfony.com"
+ },
+ {
+ "name": "Symfony Community",
+ "homepage": "https://symfony.com/contributors"
+ }
+ ],
+ "description": "Symfony Filesystem Component",
+ "homepage": "https://symfony.com",
+ "time": "2016-06-29 05:31:50"
+ },
+ {
+ "name": "symfony/polyfill-mbstring",
+ "version": "v1.2.0",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/symfony/polyfill-mbstring.git",
+ "reference": "dff51f72b0706335131b00a7f49606168c582594"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/dff51f72b0706335131b00a7f49606168c582594",
+ "reference": "dff51f72b0706335131b00a7f49606168c582594",
+ "shasum": ""
+ },
+ "require": {
+ "php": ">=5.3.3"
+ },
+ "suggest": {
+ "ext-mbstring": "For best performance"
+ },
+ "type": "library",
+ "extra": {
+ "branch-alias": {
+ "dev-master": "1.2-dev"
+ }
+ },
+ "autoload": {
+ "psr-4": {
+ "Symfony\\Polyfill\\Mbstring\\": ""
+ },
+ "files": [
+ "bootstrap.php"
+ ]
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "Nicolas Grekas",
+ "email": "p@tchwork.com"
+ },
+ {
+ "name": "Symfony Community",
+ "homepage": "https://symfony.com/contributors"
+ }
+ ],
+ "description": "Symfony polyfill for the Mbstring extension",
+ "homepage": "https://symfony.com",
+ "keywords": [
+ "compatibility",
+ "mbstring",
+ "polyfill",
+ "portable",
+ "shim"
+ ],
+ "time": "2016-05-18 14:26:46"
+ },
+ {
+ "name": "symfony/stopwatch",
+ "version": "v2.8.8",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/symfony/stopwatch.git",
+ "reference": "35bae476693150728b0eb51647faac82faf9aaca"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/symfony/stopwatch/zipball/35bae476693150728b0eb51647faac82faf9aaca",
+ "reference": "35bae476693150728b0eb51647faac82faf9aaca",
+ "shasum": ""
+ },
+ "require": {
+ "php": ">=5.3.9"
+ },
+ "type": "library",
+ "extra": {
+ "branch-alias": {
+ "dev-master": "2.8-dev"
+ }
+ },
+ "autoload": {
+ "psr-4": {
+ "Symfony\\Component\\Stopwatch\\": ""
+ },
+ "exclude-from-classmap": [
+ "/Tests/"
+ ]
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "Fabien Potencier",
+ "email": "fabien@symfony.com"
+ },
+ {
+ "name": "Symfony Community",
+ "homepage": "https://symfony.com/contributors"
+ }
+ ],
+ "description": "Symfony Stopwatch Component",
+ "homepage": "https://symfony.com",
+ "time": "2016-06-29 05:29:29"
+ },
{
"name": "symfony/yaml",
"version": "v2.8.8",
diff --git a/phpunit.xml.dist b/phpunit.xml.dist
index cc473e8..885c257 100644
--- a/phpunit.xml.dist
+++ b/phpunit.xml.dist
@@ -14,6 +14,9 @@
verbose="true"
debug="true"
>
+
+
+
./tests/Sikofitt
diff --git a/src/Sikofitt/Utility/ArrayObjectArray.php b/src/Sikofitt/Utility/ArrayObjectArray.php
index f67f414..f66dc01 100644
--- a/src/Sikofitt/Utility/ArrayObjectArray.php
+++ b/src/Sikofitt/Utility/ArrayObjectArray.php
@@ -19,8 +19,133 @@ namespace Sikofitt\Utility;
*
* @package Sikofitt\Utility
*/
-class ArrayObjectArray extends \ArrayObject
+use Guzzle\Common\Exception\BadMethodCallException;
+
+/**
+ * Class ArrayObjectArray
+ *
+ * @package Sikofitt\Utility
+ */
+class ArrayObjectArray extends \ArrayObject implements \IteratorAggregate
{
+ /**
+ * @var \ArrayIterator
+ */
+ private $iterator;
+
+ /**
+ * ArrayObjectArray constructor.
+ *
+ * @param null $input
+ * @param int $flags
+ * @param string $iterator_class
+ */
+ public function __construct(
+ $input = null,
+ $flags = 0,
+ $iterator_class = 'ArrayIterator'
+ ) {
+ // SORT_FLAG_CASE and SORT_NATURAL were introduced in php 5.4
+ if (!defined('SORT_FLAG_CASE')) { define('SORT_FLAG_CASE', 8); } elseif(!defined('SORT_NATURAL')) { define('SORT_NATURAL', 6); }
+ // ARRAY_FILTER_USE_* flags were added in php 5.6
+ // along with a 3rd parameter to use them.
+ if (!defined('ARRAY_FILTER_USE_BOTH')) { define('ARRAY_FILTER_USE_BOTH', 1); } elseif (!defined('ARRAY_FILTER_USE_KEY')) { define('ARRAY_FILTER_USE_KEY', 2); }
+ parent::__construct($input, $flags, $iterator_class);
+ $this->iterator = $this->getIterator();
+ }
+
+ /**
+ * @param string $iterator_class
+ */
+ public function setIteratorClass($iterator_class)
+ {
+ parent::setIteratorClass($iterator_class);
+ $this->iterator = $this->getIterator();
+ }
+
+ /**
+ *
+ */
+ public function pos()
+ {
+ return pos($this->iterator);
+ }
+
+ /**
+ * @return mixed
+ */
+ public function key()
+ {
+ return key($this->iterator);
+ }
+
+ /**
+ * @return mixed
+ */
+ public function current()
+ {
+ return current($this->iterator);
+ }
+
+ /**
+ *
+ */
+ public function next()
+ {
+ next($this->iterator);
+ }
+
+ /**
+ *
+ */
+ public function reset()
+ {
+ reset($this->iterator);
+ }
+
+ /**
+ * @return bool
+ */
+ public function valid()
+ {
+ return $this->iterator->valid();
+ }
+
+ /**
+ *
+ */
+ public function prev()
+ {
+ prev($this->iterator);
+ }
+
+ /**
+ *
+ */
+ public function end()
+ {
+ end($this->iterator);
+ }
+ public function each()
+ {
+ static $arrayCopy;
+
+ if(!$arrayCopy) {
+ $arrayCopy = $this->getArrayCopy();
+ }
+ return each($arrayCopy);
+ }
+ /**
+ * @param $needle
+ * @param bool $strict
+ *
+ * @return bool
+ */
+ public function in_array($needle, $strict = false)
+ {
+ return in_array($needle, $this->getArrayCopy(), $strict);
+ }
+
/**
* @param $function
* @param $argv
@@ -29,11 +154,14 @@ class ArrayObjectArray extends \ArrayObject
*/
public function __call($function, $argv)
{
- if (!is_callable($function) || substr($function, 0, 6) !== 'array_') {
- throw new \BadMethodCallException(__CLASS__ . '->' . $function);
+ if (0 !== strcasecmp($function, 'key_exists')) {
+ if (!is_callable($function) || substr($function, 0, 6) !== 'array_') {
+ throw new \BadMethodCallException(__CLASS__ . '->' . $function);
+ }
}
switch ($function) {
case 'array_key_exists':
+ case 'key_exists':
return call_user_func(
$function,
$argv[0],
@@ -62,8 +190,8 @@ class ArrayObjectArray extends \ArrayObject
* We don't need to do anything here because this
* doesn't actually touch our array. Just returns one.
*
- * @param int $startIndex
- * @param int $num
+ * @param int $startIndex
+ * @param int $num
* @param mixed $value
*
* @return array
@@ -74,4 +202,108 @@ class ArrayObjectArray extends \ArrayObject
{
return \array_fill($startIndex, $num, $value);
}
+
+ /**
+ * Alias of count
+ *
+ * @return int
+ */
+ public function sizeof()
+ {
+ return $this->count();
+ }
+
+ /**
+ * @param null|int $sort_flags
+ *
+ * @return bool
+ */
+ public function krsort($sort_flags = null)
+ {
+ $arrayCopy = $this->getArrayCopy();
+ if (@\krsort($arrayCopy, $sort_flags)) {
+ $this->exchangeArray($arrayCopy);
+ return true;
+ } else {
+ return false;
+ }
+ }
+
+ /**
+ * @param null|int $sort_flags
+ *
+ * @return bool
+ */
+ public function rsort($sort_flags = null)
+ {
+ $arrayCopy = $this->getArrayCopy();
+ if(@\rsort($arrayCopy, $sort_flags))
+ {
+ $this->exchangeArray($arrayCopy);
+ return true;
+ } else {
+ return false;
+ }
+
+ }
+
+ /**
+ * @param null|int $sort_flags
+ *
+ * @return bool
+ */
+ public function sort($sort_flags = null)
+ {
+ $arrayCopy = $this->getArrayCopy();
+ if(@\sort($arrayCopy, $sort_flags))
+ {
+ $this->exchangeArray($arrayCopy);
+ return true;
+ } else {
+ return false;
+ }
+
+ }
+
+ public function usort($callback)
+ {
+ if(!is_callable($callback))
+ {
+ throw new \BadFunctionCallException($callback);
+ }
+ $arrayCopy = $this->getArrayCopy();
+ if(true === $returnVal = @\usort($arrayCopy, $callback))
+ {
+ $this->exchangeArray($arrayCopy);
+ }
+ return $returnVal;
+ }
+ /**
+ * @param int $sort_flags
+ *
+ * @return bool
+ */
+ public function arsort($sort_flags = SORT_REGULAR)
+ {
+ $arrayCopy = $this->getArrayCopy();
+ if (@\arsort($arrayCopy, $sort_flags)) {
+ $this->exchangeArray($arrayCopy);
+
+ return true;
+ } else {
+ return false;
+ }
+ }
+
+ /**
+ * @return bool
+ */
+ public function shuffle()
+ {
+ $arrayCopy = $this->getArrayCopy();
+ if (true === $returnVal = shuffle($arrayCopy)) {
+ $this->exchangeArray($arrayCopy);
+ }
+ return $returnVal;
+ }
}
diff --git a/tests/Sikofitt/Tests/ArrayObjectArrayTest.php b/tests/Sikofitt/Tests/ArrayObjectArrayTest.php
index 6ee06fb..3463e56 100644
--- a/tests/Sikofitt/Tests/ArrayObjectArrayTest.php
+++ b/tests/Sikofitt/Tests/ArrayObjectArrayTest.php
@@ -1,413 +1,635 @@
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
-
-namespace Sikofitt\Tests;
-
-use SebastianBergmann\CodeCoverage\CodeCoverage;
-use SebastianBergmann\CodeCoverage\Driver\Xdebug;
-use Sikofitt\Utility\ArrayObjectArray;
-
-/**
- * Class ArrayObjectArrayTest
- *
- * @package Sikofitt\Tests
- *
- * @test
- *
- * array_change_key_case — Changes the case of all keys in an array
- * array_chunk — Split an array into chunks
- * array_column — Return the values from a single column in the
- * input array
- * array_combine — Creates an array by using one array for keys and
- * another for its values
- * array_count_values — Counts all the values of an array
- * array_diff_assoc — Computes the difference of arrays with additional
- * index check
- * array_diff_key — Computes the difference of arrays using keys for
- * comparison
- * array_diff_uassoc — Computes the difference of arrays with additional
- * index check which is performed by a user supplied
- * callback function.
- * array_diff_ukey — Computes the difference of arrays using a
- * callback
- * function on the keys for comparison
- * array_diff — Computes the difference of arrays
- * array_fill_keys — Fill an array with values, specifying keys
- * array_fill — Fill an array with values
- * array_filter — Filters elements of an array using a callback
- * function
- * array_flip — Exchanges all keys with their associated values
- * in
- * an array
- * array_intersect_assoc — Computes the intersection of arrays with
- * additional index check
- * array_intersect_key — Computes the intersection of arrays using keys
- * for
- * comparison
- * array_intersect_uassoc — Computes the intersection of arrays with
- * additional index check, compares indexes by a
- * callback function
- * array_intersect_ukey — Computes the intersection of arrays using a
- * callback function on the keys for comparison
- * array_intersect — Computes the intersection of arrays
- * array_key_exists — Checks if the given key or index exists in the
- * array
- * array_keys — Return all the keys or a subset of the keys of an
- * array
- * array_map — Applies the callback to the elements of the given
- * arrays
- * array_merge_recursive — Merge two or more arrays recursively
- * array_merge — Merge one or more arrays
- * array_multisort — Sort multiple or multi
- * -
- * dimensional
- * arrays
- * array_pad
- * —
- * Pad
- * array
- * to
- * the
- * specified length with a value array_pop — Pop the element off the end of array array_product — Calculate the product of values in an array array_push — Push one or more elements onto the end of array array_rand — Pick one or more random entries out of an array array_reduce — Iteratively reduce the array to a single value using a callback function array_replace_recursive — Replaces elements from passed arrays into the first array recursively array_replace — Replaces elements from passed arrays into the first array array_reverse — Return an array with elements in reverse order array_search — Searches the array for a given value and returns the corresponding key if successful array_shift — Shift an element off the beginning of array array_slice — Extract a slice of the array array_splice — Remove a portion of the array and replace it with something else array_sum — Calculate the sum of values in an array array_udiff_assoc — Computes the difference of arrays with additional index check, compares data by a callback function array_udiff_uassoc — Computes the difference of arrays with additional index check, compares data and indexes by a callback function array_udiff — Computes the difference of arrays by using a callback function for data comparison array_uintersect_assoc — Computes the intersection of arrays with additional index check, compares data by a callback function array_uintersect_uassoc — Computes the intersection of arrays with additional index check, compares data and indexes by separate callback functions array_uintersect — Computes the intersection of arrays, compares data by a callback function array_unique — Removes duplicate values from an array array_unshift — Prepend one or more elements to the beginning of an array array_values — Return all the values of an array array_walk_recursive — Apply a user function recursively to every member of an array array_walk — Apply a user supplied function to every member of an array
- *
- * Non array_* functions -
- *
- * arsort — Sort an array in reverse order and maintain index
- * association
- * asort — Sort an array and maintain index association
- * compact — Create array containing variables and their
- * values
- * count — Count all elements in an array, or something in
- * an
- * object
- * sizeof — Alias of count
- * current — Return the current element in an array
- * each — Return the current key and value pair from an
- * array and advance the array cursor end — Set the
- * internal pointer of an array to its last element extract —
- * Import variables into the current symbol table from an array in_array
- * — Checks if a value exists in an array key_exists —
- * Alias of array_key_exists key — Fetch a key
- * from an array krsort — Sort an array by key in
- * reverse order ksort — Sort an array by key list
- * — Assign variables as if they were an array
- * natcasesort — Sort an array using a
- * case insensitive "natural order" algorithm natsort — Sort an array using a "natural order" algorithm next — Advance the internal array pointer of an array pos — Alias of current prev — Rewind the internal array pointer range — Create an array containing a range of elements reset — Set the internal pointer of an array to its first element rsort — Sort an array in reverse order shuffle — Shuffle an array sort — Sort an array uasort — Sort an array with a user - defined comparison function and maintain index association uksort — Sort an array by keys using a user - defined comparison function usort — Sort an array by
- *
- */
-
-/**
- * Class ArrayObjectArrayTest
- * @coversDefaultClass Sikofitt\Utility\ArrayObjectArray
- * @package Sikofitt\Tests
- */
-class ArrayObjectArrayTest extends \PHPUnit_Framework_TestCase
-{
- private $arrayObjectArray;
- private $workingArray;
- private $workingMultiArray;
- private $arrayObjectArrayMulti;
- private $singleArrayOne;
- private $singleArrayTwo;
- private $arrayObjectSingle;
+ /*
+ * This file is part of ArrayObjectArray.
+ *
+ * (copyleft) R. Eric Wheeler
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+ namespace Sikofitt\Tests;
+ use Sikofitt\Utility\ArrayObjectArray;
/**
- * @codeCoverageIgnore
+ * Class ArrayObjectArrayTest
+ *
+ * @covers \Sikofitt\Utility\ArrayObjectArray
+ * @package Sikofitt\Tests
+ *
+ * @test
+ *
+ * array_change_key_case — Changes the case of all keys in an array
+ * array_chunk — Split an array into chunks
+ * array_column — Return the values from a single column in the
+ * input array
+ * array_combine — Creates an array by using one array for keys
+ * and another for its values array_count_values — Counts all the
+ * values of an array array_diff_assoc — Computes the difference of
+ * arrays with additional index check array_diff_key — Computes
+ * the difference of arrays using keys for comparison array_diff_uassoc
+ * — Computes the difference of arrays with additional index check which
+ * is performed by a user supplied callback function. array_diff_ukey
+ * — Computes the difference of arrays using a callback function
+ * on the keys for comparison array_diff — Computes
+ * the difference of arrays array_fill_keys — Fill an
+ * array with values, specifying keys array_fill — Fill an array with values array_filter — Filters elements of an array using a callback function array_flip — Exchanges all keys with their associated values in an array array_intersect_assoc — Computes the intersection of arrays with additional index check array_intersect_key — Computes the intersection of arrays using keys for comparison array_intersect_uassoc — Computes the intersection of arrays with additional index check, compares indexes by a callback function array_intersect_ukey — Computes the intersection of arrays using a callback function on the keys for comparison array_intersect — Computes the intersection of arrays array_key_exists — Checks if the given key or index exists in the array array_keys — Return all the keys or a subset of the keys of an array array_map — Applies the callback to the elements of the given arrays array_merge_recursive — Merge two or more arrays recursively array_merge — Merge one or more arrays array_multisort — Sort multiple or multi-dimensional arrays array_pad — Pad array to the specified length with a value array_pop — Pop the element off the end of array array_product — Calculate the product of values in an array array_push — Push one or more elements onto the end of array array_rand — Pick one or more random entries out of an array array_reduce — Iteratively reduce the array to a single value using a callback function array_replace_recursive — Replaces elements from passed arrays into the first array recursively array_replace — Replaces elements from passed arrays into the first array array_reverse — Return an array with elements in reverse order array_search — Searches the array for a given value and returns the corresponding key if successful array_shift — Shift an element off the beginning of array array_slice — Extract a slice of the array array_splice — Remove a portion of the array and replace it with something else array_sum — Calculate the sum of values in an array array_udiff_assoc — Computes the difference of arrays with additional index check, compares data by a callback function array_udiff_uassoc — Computes the difference of arrays with additional index check, compares data and indexes by a callback function array_udiff — Computes the difference of arrays by using a callback function for data comparison a rray_uintersect_assoc — Computes the intersection of arrays with additional index check, compares data by a callback function array_uintersect_uassoc — Computes the intersection of arrays with additional index check, compares data and indexes by separate callback functions array_uintersect — Computes the intersection of arrays, compares data by a callback function array_unique — Removes duplicate values from an array array_unshift — Prepend one or more elements to the beginning of an array array_values — Return all the values of an array array_walk_recursive — Apply a user function recursively to every member of an array array_walk — Apply a user supplied function to every member of an array
+ *
+ * Non array_* prefixed functions
+ *
+ * arsort — Sort an array in reverse order and maintain
+ * index association current — Return the current element
+ * in an array
+ ** each — Return the current key and value pair from an array and advance the array cursor
+ * end — Set the internal pointer of an array to its
+ * last element in_array — Checks if a value exists in an
+ * array key_exists — Alias of array_key_exists key
+ * — Fetch a key from an array krsort — Sort an
+ * array by key in reverse order next — Advance
+ * the internal array pointer of an array pos
+ * — Alias of current prev — Rewind the
+ * internal array pointer reset — Set the
+ * internal pointer of an array to its first element rsort
+ * — Sort an array in reverse order shuffle
+ * — Shuffle an array sizeof — Alias of count sort — Sort an array usort — Sort an array by values using a user-defined comparison function
*/
- public function setUp()
+ class ArrayObjectArrayTest extends \PHPUnit_Framework_TestCase
{
+ /**
+ * @var ArrayObjectArray
+ * default ArrayObjectArray class to work with
+ */
+ private $arrayObjectArray;
- $this->workingArray = array(
- 'this' => 'THAT',
- 'that' => 'this',
- 'WHAT' => 'who',
- 'check' => 'out',
- );
- $this->workingMultiArray = array(
- array(
- 'id' => 2135,
- 'first_name' => 'John',
- 'last_name' => 'Doe',
- ),
- array(
- 'id' => 3245,
- 'first_name' => 'Sally',
- 'last_name' => 'Smith',
- ),
- array(
- 'id' => 5342,
- 'first_name' => 'Jane',
- 'last_name' => 'Jones',
- ),
- array(
- 'id' => 5623,
- 'first_name' => 'Peter',
- 'last_name' => 'Doe',
- ),
- );
- $this->singleArrayOne = array('green', 'red', 'yellow');
- $this->singleArrayTwo = array('avocado', 'apple', 'banana');
+ /**
+ * @var array
+ * default Array to work with
+ */
+ private $workingArray;
- $this->arrayObjectArray = new ArrayObjectArray($this->workingArray);
- $this->arrayObjectArrayMulti = new ArrayObjectArray($this->workingMultiArray);
- $this->arrayObjectSingle = new ArrayObjectArray($this->singleArrayOne);
- }
+ /**
+ * @var array
+ * multi-dimensional array to work with
+ */
+ private $workingMultiArray;
- /**
- * @covers Sikofitt\Utility\ArrayObjectArray::__construct
- */
- public function testObjectArrayIsExtended()
- {
- $this->assertInstanceOf('Sikofitt\Utility\ArrayObjectArray', $this->arrayObjectArray);
- $this->assertInstanceOf('\ArrayObject', $this->arrayObjectArray);
+ /**
+ * @var ArrayObjectArray
+ * multi-dimensional ArrayObjectArray to work with
+ */
+ private $arrayObjectArrayMulti;
- $this->assertSame($this->workingArray, $this->arrayObjectArray->getArrayCopy());
- $this->assertCount(4, $this->arrayObjectArray);
+ /**
+ * @var array
+ * Single array to work with
+ */
+ private $singleArrayOne;
- $this->arrayObjectArray->offsetUnset('this');
- $this->assertCount(3, $this->arrayObjectArray);
+ /**
+ * @var array
+ * Second single array to work with
+ */
+ private $singleArrayTwo;
- $this->arrayObjectArray->append(array('this' => 'that'));
- $this->assertCount(4, $this->arrayObjectArray);
- }
+ /**
+ * @var ArrayObjectArray
+ * Single ArrayObjectArray class to work with
+ */
+ private $arrayObjectSingle;
- /**
- * @codeCoverageIgnore
- */
- public function resetWorkingArray()
- {
- $this->workingArray = array(
- 'this' => 'THAT',
- 'that' => 'this',
- 'WHAT' => 'who',
- 'check' => 'out',
- );
- $this->workingMultiArray = array(
- array(
- 'id' => 2135,
- 'first_name' => 'John',
- 'last_name' => 'Doe',
- ),
- array(
- 'id' => 3245,
- 'first_name' => 'Sally',
- 'last_name' => 'Smith',
- ),
- array(
- 'id' => 5342,
- 'first_name' => 'Jane',
- 'last_name' => 'Jones',
- ),
- array(
- 'id' => 5623,
- 'first_name' => 'Peter',
- 'last_name' => 'Doe',
- ),
- );
- $this->singleArrayOne = array('green', 'red', 'yellow');
+ /**
+ * @codeCoverageIgnore
+ */
+ public function setUp()
+ {
+ $this->workingArray = array(
+ 'this' => 'THAT',
+ 'that' => 'this',
+ 'WHAT' => 'who',
+ 'check' => 'out',
+ );
+ $this->workingMultiArray = array(
+ array(
+ 'id' => 2135,
+ 'first_name' => 'John',
+ 'last_name' => 'Doe',
+ ),
+ array(
+ 'id' => 3245,
+ 'first_name' => 'Sally',
+ 'last_name' => 'Smith',
+ ),
+ array(
+ 'id' => 5342,
+ 'first_name' => 'Jane',
+ 'last_name' => 'Jones',
+ ),
+ array(
+ 'id' => 5623,
+ 'first_name' => 'Peter',
+ 'last_name' => 'Doe',
+ ),
+ );
+ $this->singleArrayOne = array('green', 'red', 'yellow');
+ $this->singleArrayTwo = array('avocado', 'apple', 'banana');
- $this->arrayObjectArray->exchangeArray($this->workingArray);
- $this->arrayObjectArrayMulti->exchangeArray($this->workingMultiArray);
- $this->arrayObjectSingle->exchangeArray($this->singleArrayOne);
- }
+ $this->arrayObjectArray = new ArrayObjectArray($this->workingArray);
+ $this->arrayObjectArrayMulti = new ArrayObjectArray($this->workingMultiArray);
+ $this->arrayObjectSingle = new ArrayObjectArray($this->singleArrayOne);
+ }
- /**
- * @covers Sikofitt\Utility\ArrayObjectArray::__call
- * @covers Sikofitt\Utility\ArrayObjectArray::array_fill
- */
- public function testArrayFunctions() {
- $key_comp_function = function ($a, $b) {
- if ($a === $b) {
- return 0;
- }
+ /**
+ * @covers Sikofitt\Utility\ArrayObjectArray::__construct
+ */
+ public function testObjectArrayIsExtended()
+ {
+ $this->assertInstanceOf('Sikofitt\Utility\ArrayObjectArray', $this->arrayObjectArray);
+ $this->assertInstanceOf('\ArrayObject', $this->arrayObjectArray);
- return ($a > $b) ? 1 : -1;
- };
- $array_filter = function ($a) {
- return $a & 1;
- };
- // array_change_key_case
- $this->assertSame(array_change_key_case($this->workingArray, CASE_UPPER), $this->arrayObjectArray->array_change_key_case(CASE_UPPER));
- $this->assertSame(array_change_key_case($this->workingArray, CASE_LOWER), $this->arrayObjectArray->array_change_key_case(CASE_LOWER));
- // array_chunk
- $this->assertSame(array_chunk($this->workingArray, 2), $this->arrayObjectArray->array_chunk(2));
- $this->assertSame(array_chunk($this->workingArray, 2, true), $this->arrayObjectArray->array_chunk(2, true));
- // array_column
- //if (PHP_VERSION_ID >= 50500) {
+ $this->assertSame($this->workingArray, $this->arrayObjectArray->getArrayCopy());
+ $this->assertCount(4, $this->arrayObjectArray);
+
+ $this->arrayObjectArray->offsetUnset('this');
+ $this->assertCount(3, $this->arrayObjectArray);
+
+ $this->arrayObjectArray->append(array('this' => 'that'));
+ $this->assertCount(4, $this->arrayObjectArray);
+ }
+
+ /**
+ * @codeCoverageIgnore
+ */
+ public function resetWorkingArray()
+ {
+ $this->workingArray = array(
+ 'this' => 'THAT',
+ 'that' => 'this',
+ 'WHAT' => 'who',
+ 'check' => 'out',
+ );
+ $this->workingMultiArray = array(
+ array(
+ 'id' => 2135,
+ 'first_name' => 'John',
+ 'last_name' => 'Doe',
+ ),
+ array(
+ 'id' => 3245,
+ 'first_name' => 'Sally',
+ 'last_name' => 'Smith',
+ ),
+ array(
+ 'id' => 5342,
+ 'first_name' => 'Jane',
+ 'last_name' => 'Jones',
+ ),
+ array(
+ 'id' => 5623,
+ 'first_name' => 'Peter',
+ 'last_name' => 'Doe',
+ ),
+ );
+ $this->singleArrayOne = array('green', 'red', 'yellow');
+
+ $this->arrayObjectArray->exchangeArray($this->workingArray);
+ $this->arrayObjectArrayMulti->exchangeArray($this->workingMultiArray);
+ $this->arrayObjectSingle->exchangeArray($this->singleArrayOne);
+ }
+
+ /**
+ * @covers Sikofitt\Utility\ArrayObjectArray::__call
+ * @covers Sikofitt\Utility\ArrayObjectArray::array_fill
+ */
+ public function testArrayFunctions()
+ {
+ $key_comp_function = function ($a, $b)
+ {
+
+ if ($a === $b)
+ {
+ return 0;
+ }
+
+ return ($a > $b) ? 1 : -1;
+ };
+ $array_filter = function ($a)
+ {
+ return $a & 1;
+ };
+ // array_change_key_case
+ $this->assertSame(array_change_key_case($this->workingArray, CASE_UPPER), $this->arrayObjectArray->array_change_key_case(CASE_UPPER));
+ $this->assertSame(array_change_key_case($this->workingArray, CASE_LOWER), $this->arrayObjectArray->array_change_key_case(CASE_LOWER));
+ // array_chunk
+ $this->assertSame(array_chunk($this->workingArray, 2), $this->arrayObjectArray->array_chunk(2));
+ $this->assertSame(array_chunk($this->workingArray, 2, true), $this->arrayObjectArray->array_chunk(2, true));
+ // array_column
+ //if (PHP_VERSION_ID >= 50500) {
$this->assertSame(array_column($this->workingMultiArray, 'first_name'), $this->arrayObjectArrayMulti->array_column('first_name'));
$this->assertSame(array_column($this->workingMultiArray, 'first_name', 'id'), $this->arrayObjectArrayMulti->array_column('first_name', 'id'));
- //}
- // array_combine
- $this->assertSame(array_combine($this->singleArrayOne, $this->singleArrayTwo), $this->arrayObjectSingle->array_combine($this->singleArrayTwo));
- // array_count_values
- $this->assertSame(array_count_values($this->workingArray), $this->arrayObjectArray->array_count_values());
- // array_diff_assoc
- $this->assertSame(array_diff_assoc($this->workingMultiArray, $this->workingArray), $this->arrayObjectArrayMulti->array_diff_assoc($this->workingArray));
- // array_diff_key
- $this->assertSame(array_diff_key($this->workingArray, array_flip($this->workingArray)), $this->arrayObjectArray->array_diff_key(array_flip($this->workingArray)));
- // array_diff_uassoc
- $this->assertSame(array_diff_uassoc($this->workingMultiArray, $this->workingArray, $key_comp_function), $this->arrayObjectArrayMulti->array_diff_uassoc($this->workingArray, $key_comp_function));
- // array_diff_ukey
- $this->assertSame(array_diff_ukey($this->workingMultiArray, $this->workingArray, $key_comp_function), $this->arrayObjectArrayMulti->array_diff_ukey($this->workingArray, $key_comp_function));
- // array_diff
- $this->assertSame(array_diff($this->singleArrayOne, $this->workingArray), $this->arrayObjectSingle->array_diff($this->workingArray));
- // array_fill_keys
- $this->assertSame(array_fill_keys($this->singleArrayOne, 'banana'), $this->arrayObjectSingle->array_fill_keys('banana'));
- // array_fill
- $this->assertSame(array_fill(5, 6, 'banana'), $this->arrayObjectArray->array_fill(5, 6, 'banana'));
- // array_filter
- $this->assertSame(array_filter($this->workingMultiArray), $this->arrayObjectArrayMulti->array_filter());
- $this->assertSame(array_filter($this->workingMultiArray, $array_filter), $this->arrayObjectArrayMulti->array_filter($array_filter));
- // The third parameter was added in php 5.6
- if(!defined('ARRAY_FILTER_USE_BOTH')) {
- define('ARRAY_FILTER_USE_BOTH', 1);
- }
- if(!defined('ARRAY_FILTER_USE_KEY')) {
- define('ARRAY_FILTER_USE_KEY', 2);
+ //}
+ // array_combine
+ $this->assertSame(array_combine($this->singleArrayOne, $this->singleArrayTwo), $this->arrayObjectSingle->array_combine($this->singleArrayTwo));
+ // array_count_values
+ $this->assertSame(array_count_values($this->workingArray), $this->arrayObjectArray->array_count_values());
+ // array_diff_assoc
+ $this->assertSame(array_diff_assoc($this->workingMultiArray, $this->workingArray), $this->arrayObjectArrayMulti->array_diff_assoc($this->workingArray));
+ // array_diff_key
+ $this->assertSame(array_diff_key($this->workingArray, array_flip($this->workingArray)), $this->arrayObjectArray->array_diff_key(array_flip($this->workingArray)));
+ // array_diff_uassoc
+ $this->assertSame(array_diff_uassoc($this->workingMultiArray, $this->workingArray, $key_comp_function), $this->arrayObjectArrayMulti->array_diff_uassoc($this->workingArray, $key_comp_function));
+ // array_diff_ukey
+ $this->assertSame(array_diff_ukey($this->workingMultiArray, $this->workingArray, $key_comp_function), $this->arrayObjectArrayMulti->array_diff_ukey($this->workingArray, $key_comp_function));
+ // array_diff
+ $this->assertSame(array_diff($this->singleArrayOne, $this->workingArray), $this->arrayObjectSingle->array_diff($this->workingArray));
+ // array_fill_keys
+ $this->assertSame(array_fill_keys($this->singleArrayOne, 'banana'), $this->arrayObjectSingle->array_fill_keys('banana'));
+ // array_fill
+ $this->assertSame(array_fill(5, 6, 'banana'), $this->arrayObjectArray->array_fill(5, 6, 'banana'));
+ // array_filter
+ $this->assertSame(array_filter($this->workingMultiArray), $this->arrayObjectArrayMulti->array_filter());
+ $this->assertSame(array_filter($this->workingMultiArray, $array_filter), $this->arrayObjectArrayMulti->array_filter($array_filter));
+
+ // The third parameter for array_filter was added in php 5.6 and does
+ // not exist in hhvm
+ if (PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION'))
+ {
+ $this->assertSame(array_filter($this->workingMultiArray, $array_filter, ARRAY_FILTER_USE_BOTH), $this->arrayObjectArrayMulti->array_filter($array_filter, ARRAY_FILTER_USE_BOTH));
+ $this->assertSame(array_filter($this->workingMultiArray, $array_filter, ARRAY_FILTER_USE_KEY), $this->arrayObjectArrayMulti->array_filter($array_filter, ARRAY_FILTER_USE_KEY));
+ }
+ // array_flip
+ $this->assertSame(array_flip($this->workingArray), $this->arrayObjectArray->array_flip());
+ $this->assertSame(array_flip($this->singleArrayOne), $this->arrayObjectSingle->array_flip());
+ $this->assertNotSame(array_flip($this->singleArrayTwo), $this->arrayObjectSingle->array_flip());
+ // array_intersect_assoc
+ $this->assertSame(array_intersect_assoc($this->workingArray, $this->singleArrayOne), $this->arrayObjectArray->array_intersect_assoc($this->singleArrayOne));
+ // array_intersect_key
+ $this->assertSame(array_intersect_key($this->workingArray, $this->singleArrayOne), $this->arrayObjectArray->array_intersect_key($this->singleArrayOne));
+ // array_intersect_uassoc
+ $this->assertSame(array_intersect_uassoc($this->workingArray, $this->singleArrayOne, 'strcasecmp'), $this->arrayObjectArray->array_intersect_uassoc($this->singleArrayOne, 'strcasecmp'));
+ // array_intersect_ukey
+ $this->assertSame(array_intersect_ukey($this->workingArray, $this->singleArrayOne, $key_comp_function), $this->arrayObjectArray->array_intersect_ukey($this->singleArrayOne, $key_comp_function));
+ // array_intersect
+ $this->assertSame(array_intersect($this->workingArray, $this->singleArrayOne), $this->arrayObjectArray->array_intersect($this->singleArrayOne));
+ // array_key_exists
+ $this->assertSame(array_key_exists('this', $this->workingArray), $this->arrayObjectArray->array_key_exists('this'));
+ $this->assertFalse($this->arrayObjectArray->array_key_exists('banana'));
+ // array_keys
+ $this->assertSame(array_keys($this->workingArray), $this->arrayObjectArray->array_keys());
+ $this->assertSame(array_keys($this->workingArray, 'this'), $this->arrayObjectArray->array_keys('this'));
+ $this->assertSame(array_keys($this->workingArray, 'this', true), $this->arrayObjectArray->array_keys('this', true));
+ $this->assertSame(array(), $this->arrayObjectArray->array_keys('banana'));
+
+ // array_values
+ $this->assertSame(array_values($this->workingArray), $this->arrayObjectArray->array_values());
+ // array_merge_recursive
+ $this->assertSame(array_merge_recursive($this->workingArray, $this->workingMultiArray), $this->arrayObjectArray->array_merge_recursive($this->workingMultiArray));
+ $this->assertSame(array_merge_recursive($this->workingArray, $this->workingMultiArray, $this->singleArrayTwo), $this->arrayObjectArray->array_merge_recursive($this->workingMultiArray, $this->singleArrayTwo));
+ // array_merge
+ $this->assertSame(array_merge($this->workingArray, $this->workingMultiArray), $this->arrayObjectArray->array_merge($this->workingMultiArray));
+ $this->assertSame(array_merge($this->workingArray, $this->workingMultiArray, $this->singleArrayTwo), $this->arrayObjectArray->array_merge($this->workingMultiArray, $this->singleArrayTwo));
+ $this->assertSame(array_merge($this->workingArray, (array) 'start'), $this->arrayObjectArray->array_merge((array) 'start'));
+
+ // array_multisort
+ $this->assertSame(array_multisort($this->singleArrayOne, $this->singleArrayTwo), $this->arrayObjectSingle->array_multisort($this->singleArrayTwo));
+ // array_multisort complex
+ /** @NOTE: For custom sorting on the array in ArrayObjectArray, just enter the flags. */
+ $this->assertSame(
+ array_multisort(
+ $this->singleArrayOne, SORT_ASC, SORT_STRING,
+ $this->singleArrayTwo, SORT_NUMERIC, SORT_DESC
+ ),
+ $this->arrayObjectSingle->array_multisort(
+ SORT_ASC, SORT_STRING,
+ $this->singleArrayTwo, SORT_NUMERIC, SORT_DESC
+ )
+ );
+ // array_pad
+
+ $this->assertSame(array_pad($this->workingArray, 6, 'hello'), $this->arrayObjectArray->array_pad(6, 'hello'));
+ // array_pop
+ // array_product
+ // array_push
+ // array_rand
+ // array_reduce
+ // array_replace_recursive
+ // array_replace
+ // array_reverse
+ // array_search
+ // array_shift
+ // array_slice
+ // array_splice
+ // array_sum
+ // array_udiff_assoc
+ // array_udiff_uassoc
+ // array_udiff
+ // array_uintersect_assoc
+ // array_uintersect_uassoc
+ // array_uintersect
+ // array_unique
+ // array_unshift
+ // array_values
+ // array_walk_recursive
+ // array_walk
}
- if (PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION')) {
- $this->assertSame(array_filter($this->workingMultiArray, $array_filter, ARRAY_FILTER_USE_BOTH), $this->arrayObjectArrayMulti->array_filter($array_filter, ARRAY_FILTER_USE_BOTH));
- $this->assertSame(array_filter($this->workingMultiArray, $array_filter, ARRAY_FILTER_USE_KEY), $this->arrayObjectArrayMulti->array_filter($array_filter, ARRAY_FILTER_USE_KEY));
+ /**
+ * @covers Sikofitt\Utility\ArrayObjectArray::arsort
+ */
+ public function testArsort()
+ {
+ $data = $this->arrayObjectArrayData();
+
+ $arrayObjectArray = new ArrayObjectArray($data['numeric']);
+ arsort($data['numeric']);
+ $this->assertTrue($arrayObjectArray->arsort());
+ $this->assertSame($data['numeric'], $arrayObjectArray->getArrayCopy());
+ $data = null;
+ $data = $this->arrayObjectArrayData();
+ $arrayObjectArray->exchangeArray($data['numeric']);
+ arsort($data['numeric'], SORT_STRING);
+ $this->assertTrue($arrayObjectArray->arsort(SORT_STRING));
+ $this->assertSame($data['numeric'], $arrayObjectArray->getArrayCopy());
+ $data = null;
+ $data = $this->arrayObjectArrayData();
+ $arrayObjectArray->exchangeArray($data['alpha']);
+ arsort($data['alpha'], SORT_NUMERIC);
+ $this->assertTrue($arrayObjectArray->arsort(SORT_NUMERIC));
+ $this->assertSame($data['alpha'], $arrayObjectArray->getArrayCopy());
+ $data = null;
+ $data = $this->arrayObjectArrayData();
+ $arrayObjectArray->exchangeArray($data['multi']);
+ arsort($data['multi'], SORT_FLAG_CASE | SORT_NATURAL);
+ $this->assertTrue($arrayObjectArray->arsort(SORT_FLAG_CASE | SORT_NATURAL));
+ $this->assertSame($data['multi'], $arrayObjectArray->getArrayCopy());
+ $arrayObjectArray->exchangeArray(array('string'));
+ $this->assertFalse($arrayObjectArray->arsort('string'));
}
- // array_flip
- $this->assertSame(array_flip($this->workingArray), $this->arrayObjectArray->array_flip());
- $this->assertSame(array_flip($this->singleArrayOne), $this->arrayObjectSingle->array_flip());
- $this->assertNotSame(array_flip($this->singleArrayTwo), $this->arrayObjectSingle->array_flip());
- // array_intersect_assoc
- $this->assertSame(array_intersect_assoc($this->workingArray, $this->singleArrayOne), $this->arrayObjectArray->array_intersect_assoc($this->singleArrayOne));
- // array_intersect_key
- $this->assertSame(array_intersect_key($this->workingArray, $this->singleArrayOne), $this->arrayObjectArray->array_intersect_key($this->singleArrayOne));
- // array_intersect_uassoc
- $this->assertSame(array_intersect_uassoc($this->workingArray, $this->singleArrayOne, 'strcasecmp'), $this->arrayObjectArray->array_intersect_uassoc($this->singleArrayOne, 'strcasecmp'));
- // array_intersect_ukey
- $this->assertSame(array_intersect_ukey($this->workingArray, $this->singleArrayOne, $key_comp_function), $this->arrayObjectArray->array_intersect_ukey($this->singleArrayOne, $key_comp_function));
- // array_intersect
- $this->assertSame(array_intersect($this->workingArray, $this->singleArrayOne), $this->arrayObjectArray->array_intersect($this->singleArrayOne));
- // array_key_exists
- $this->assertSame(array_key_exists('this', $this->workingArray), $this->arrayObjectArray->array_key_exists('this'));
- $this->assertFalse($this->arrayObjectArray->array_key_exists('banana'));
- // array_keys
- $this->assertSame(array_keys($this->workingArray), $this->arrayObjectArray->array_keys());
- $this->assertSame(array_keys($this->workingArray, 'this'), $this->arrayObjectArray->array_keys('this'));
- $this->assertSame(array_keys($this->workingArray, 'this', true), $this->arrayObjectArray->array_keys('this', true));
- $this->assertSame(array(), $this->arrayObjectArray->array_keys('banana'));
- // array_values
- $this->assertSame(array_values($this->workingArray), $this->arrayObjectArray->array_values());
- // array_merge_recursive
- $this->assertSame(array_merge_recursive($this->workingArray, $this->workingMultiArray), $this->arrayObjectArray->array_merge_recursive($this->workingMultiArray));
- $this->assertSame(array_merge_recursive($this->workingArray, $this->workingMultiArray, $this->singleArrayTwo), $this->arrayObjectArray->array_merge_recursive($this->workingMultiArray, $this->singleArrayTwo));
- // array_merge
- $this->assertSame(array_merge($this->workingArray, $this->workingMultiArray), $this->arrayObjectArray->array_merge($this->workingMultiArray));
- $this->assertSame(array_merge($this->workingArray, $this->workingMultiArray, $this->singleArrayTwo), $this->arrayObjectArray->array_merge($this->workingMultiArray, $this->singleArrayTwo));
- $this->assertSame(array_merge($this->workingArray, (array) 'start'), $this->arrayObjectArray->array_merge((array) 'start'));
+ public function arrayObjectArrayData()
+ {
+ return array(
+ 'numeric' => array(1, 2, 3, 4, 5, 6, 7, 8, 9, 0),
+ 'alpha' => array(
+ 'one',
+ 'two',
+ 'three',
+ 'four',
+ 'five',
+ 'six',
+ 'seven',
+ 'eight',
+ 'nine',
+ 'zero',
+ ),
+ 'multi' => array(
+ 'one' => 'two',
+ 'two' => 'three',
+ 'three' => 'four',
+ 'four' => 'five',
+ 'five' => 'six',
+ 'six' => 'seven',
+ 'seven' => 'eight',
+ 'eight' => 'nine',
+ 'nine' => 'zero',
+ ),
+ );
+ }
- // array_multisort
- $this->assertSame(array_multisort($this->singleArrayOne, $this->singleArrayTwo), $this->arrayObjectSingle->array_multisort($this->singleArrayTwo));
- // array_multisort complex
- /** @NOTE: For custom sorting on the array in ArrayObjectArray, just enter the flags. */
- $this->assertSame(
- array_multisort(
- $this->singleArrayOne, SORT_ASC, SORT_STRING,
- $this->singleArrayTwo, SORT_NUMERIC, SORT_DESC
- ),
- $this->arrayObjectSingle->array_multisort(
- SORT_ASC, SORT_STRING,
- $this->singleArrayTwo, SORT_NUMERIC, SORT_DESC
- )
- );
- // array_pad
- // array_pop
- // array_product
- // array_push
- // array_rand
- // array_reduce
- // array_replace_recursive
- // array_replace
- // array_reverse
- // array_search
- // array_shift
- // array_slice
- // array_splice
- // array_sum
- // array_udiff_assoc
- // array_udiff_uassoc
- // array_udiff
- // array_uintersect_assoc
- // array_uintersect_uassoc
- // array_uintersect
- // array_unique
- // array_unshift
- // array_values
- // array_walk_recursive
- // array_walk
+ /**
+ * @covers Sikofitt\Utility\ArrayObjectArray::setIteratorClass
+ */
+ public function testSetIteratorClass()
+ {
+ $arrayObjectArray = new ArrayObjectArray(array());
+ $this->assertSame($arrayObjectArray->getIteratorClass(), 'ArrayIterator');
+ $arrayObjectArray->setIteratorClass('RecursiveArrayIterator');
+ $this->assertSame($arrayObjectArray->getIteratorClass(), 'RecursiveArrayIterator');
+ }
+
+ /**
+ * @covers Sikofitt\Utility\ArrayObjectArray::current
+ * @covers Sikofitt\Utility\ArrayObjectArray::reset
+ * @covers Sikofitt\Utility\ArrayObjectArray::next
+ * @covers Sikofitt\Utility\ArrayObjectArray::valid
+ * @covers Sikofitt\Utility\ArrayObjectArray::key
+ * @covers Sikofitt\Utility\ArrayObjectArray::prev
+ * @covers Sikofitt\Utility\ArrayObjectArray::pos
+ */
+ public function testArrayIterator()
+ {
+ $data = null;
+ $data = $this->arrayObjectArrayData();
+ $arrayObjectArray = new ArrayObjectArray($data['alpha']);
+ $arrayObjectArray->reset();
+ $this->assertSame('one', $arrayObjectArray->current());
+ $arrayObjectArray->next();
+ $this->assertSame('two', $arrayObjectArray->current());
+ $this->assertSame('two', $arrayObjectArray->pos());
+ $arrayObjectArray->prev();
+ $this->assertSame('one', $arrayObjectArray->pos());
+ $arrayObjectArray->next();
+ $this->assertSame(1, $arrayObjectArray->key());
+ $arrayObjectArray->prev();
+ $this->assertSame('one', $arrayObjectArray->current());
+ $this->assertSame('one', $arrayObjectArray->pos());
+ $this->assertSame(0, $arrayObjectArray->key());
+ $this->assertTrue($arrayObjectArray->valid());
+ $arrayObjectArray->end();
+ $this->assertSame('zero', $arrayObjectArray->pos());
+ }
+
+ /**
+ * @covers \Sikofitt\Utility\ArrayObjectArray::in_array
+ */
+ public function testInArray()
+ {
+ $data = $this->arrayObjectArrayData();
+ $arrayObjectArray = new ArrayObjectArray($data['multi']);
+ $this->assertFalse($arrayObjectArray->in_array('one'));
+ $this->assertTrue($arrayObjectArray->in_array('zero'));
+ $this->assertSame(in_array('one', $data['multi'], true), $arrayObjectArray->in_array('one'));
+ $arrayObjectArray->exchangeArray($data['numeric']);
+ $this->assertFalse($arrayObjectArray->in_array('1', true, true));
+ $this->assertTrue($arrayObjectArray->in_array('1'));
+ $arrayObjectArray->sizeof();
+ }
+
+ /**
+ * @covers \Sikofitt\Utility\ArrayObjectArray::shuffle
+ */
+ public function testShuffle()
+ {
+ $data = $this->arrayObjectArrayData();
+ $arrayObjectArray = new ArrayObjectArray($data['numeric']);
+ $this->assertSame($data['numeric'], $arrayObjectArray->getArrayCopy());
+ $arrayObjectArray->shuffle();
+ $this->assertNotSame($data['numeric'], $arrayObjectArray->getArrayCopy());
+ }
+
+ public function testKrsort()
+ {
+ $data = $this->arrayObjectArrayData();
+ $arrayObjectArray = new ArrayObjectArray($data['alpha']);
+ $this->assertSame($data['alpha'], $arrayObjectArray->getArrayCopy());
+ $arrayObjectArray->krsort();
+ $this->assertNotSame($data['alpha'], $arrayObjectArray->getArrayCopy());
+ krsort($data['alpha']);
+ $this->assertSame($data['alpha'], $arrayObjectArray->getArrayCopy());
+ $this->assertFalse($arrayObjectArray->krsort('string'));
+ }
+
+ /**
+ * @covers Sikofitt\Utility\ArrayObjectArray::rsort
+ */
+ public function testRsort()
+ {
+ $data = $this->arrayObjectArrayData();
+ $arrayObjectArray = new ArrayObjectArray($data['alpha']);
+ $this->assertSame($data['alpha'], $arrayObjectArray->getArrayCopy());
+ $arrayObjectArray->rsort();
+ $this->assertNotSame($data['alpha'], $arrayObjectArray->getArrayCopy());
+ rsort($data['alpha']);
+ $this->assertSame($data['alpha'], $arrayObjectArray->getArrayCopy());
+ $this->assertFalse($arrayObjectArray->rsort('string'));
+ }
+
+ /**
+ * @covers Sikofitt\Utility\ArrayObjectArray::sort
+ */
+ public function testSort()
+ {
+ $data = $this->arrayObjectArrayData();
+ $arrayObjectArray = new ArrayObjectArray($data['alpha']);
+ $this->assertSame($data['alpha'], $arrayObjectArray->getArrayCopy());
+ $arrayObjectArray->sort();
+ $this->assertNotSame($data['alpha'], $arrayObjectArray->getArrayCopy());
+ sort($data['alpha']);
+ $this->assertSame($data['alpha'], $arrayObjectArray->getArrayCopy());
+ $this->assertFalse($arrayObjectArray->sort('string'));
+ }
+
+ /**
+ * @covers Sikofitt\Utility\ArrayObjectArray::usort
+ */
+ public function testUsort()
+ {
+ $data = $this->arrayObjectArrayData();
+ $arrayObjectArray = new ArrayObjectArray($data['numeric']);
+ $this->assertSame($data['numeric'], $arrayObjectArray->getArrayCopy());
+ usort($data['numeric'], 'strcasecmp');
+ $this->assertTrue($arrayObjectArray->usort('in_array'));
+ $this->assertNotSame($data['numeric'], $arrayObjectArray->getArrayCopy());
+ $this->assertTrue($arrayObjectArray->usort('strcasecmp'));
+ $this->assertSame($data['numeric'], $arrayObjectArray->getArrayCopy());
+
+ }
+
+ /**
+ * @covers Sikofitt\Utility\ArrayObjectArray::usort
+ * @expectedException \BadFunctionCallException
+ */
+ public function testUsortTypeError()
+ {
+ $data = $this->arrayObjectArrayData();
+ $arrayObjectArray = new ArrayObjectArray($data['numeric']);
+ $arrayObjectArray->usort('none');
+ }
+
+
+ /**
+ * @covers Sikofitt\Utility\ArrayObjectArray::each
+ */
+ public function testEach()
+ {
+ $data = $this->arrayObjectArrayData();
+ $arrayObjectArray = new ArrayObjectArray($data['alpha']);
+
+ $defaultEach = function() use ($data) {
+ $returnArray = array();
+ while(list($key, $value) = each($data['alpha']))
+ {
+ $returnArray[] = sprintf("%s => %s", $key, $value);
+
+ }
+ return $returnArray;
+ };
+ $arrayObjectEach = function() use($arrayObjectArray) {
+ $returnArray = array();
+ while(list($key, $value) = $arrayObjectArray->each())
+ {
+ $returnArray[] = sprintf("%s => %s", $key, $value);
+
+ }
+ return $returnArray;
+ };
+
+ $this->assertSame($defaultEach(), $arrayObjectEach());
+
+ }
+
+ /**
+ * @covers \Sikofitt\Utility\ArrayObjectArray::__call
+ * array_map
+ */
+ public function testArrayMap()
+ {
+ // array_map
+ $cube = function ($n)
+ {
+ return ($n * $n * $n);
+ };
+
+ $timesTwo = function ($value)
+ {
+ return $value * 2;
+ };
+ $showSpanish = function ($digit, $spanishNum)
+ {
+ return ("The number $digit is called $spanishNum in Spanish");
+ };
+
+ $mapSpanish = function ($digit, $spanishNum)
+ {
+ return (array($digit => $spanishNum));
+ };
+
+ $callbackOne = function ($a)
+ {
+ return array($a);
+ };
+
+ $callbackTwo = function ($a, $b)
+ {
+ return array($a, $b);
+ };
+
+ $a = array(1, 2, 3, 4, 5);
+ $b = array("uno", "dos", "tres", "cuatro", "cinco");
+ $c = array("one", "two", "three", "four", "five");
+
+ $arrayObjectArray = new ArrayObjectArray($a);
+
+ $this->assertSame(array_map($cube, $a), $arrayObjectArray->array_map($cube));
+ $arrayObjectArray->exchangeArray(range(1, 5));
+ $this->assertSame(array_map($timesTwo, range(1, 5)), $arrayObjectArray->array_map($timesTwo));
+ $arrayObjectArray->exchangeArray($a);
+ $this->assertSame(array_map($showSpanish, $a, $b), $arrayObjectArray->array_map($showSpanish, $b));
+ $this->assertSame(array_map($mapSpanish, $a, $b), $arrayObjectArray->array_map($mapSpanish, $b));
+ $this->assertSame(array_map(null, $a, $b, $c), $arrayObjectArray->array_map(null, $b, $c));
+ $arrayObjectArray->exchangeArray($this->workingArray);
+ $this->assertSame(array_map($callbackOne, $this->workingArray), $arrayObjectArray->array_map($callbackOne));
+ $this->assertSame(array_map($callbackTwo, $this->workingArray, $this->workingArray), $arrayObjectArray->array_map($callbackTwo, $this->workingArray));
+ $this->assertSame(array_map(null, $this->workingArray), $arrayObjectArray->array_map(null));
+ $this->assertSame(array_map(null, $this->workingArray, $this->workingArray), $arrayObjectArray->array_map(null, $this->workingArray));
+ }
+
+ /**
+ * @expectedException \BadMethodCallException
+ */
+ public function testException()
+ {
+ $this->arrayObjectArray->error();
+ }
}
-
- /**
- * @codeCoverageIgnore
- */
- public function testArrayMap()
- {
- // array_map
- $cube = function ($n) {
- return ($n * $n * $n);
- };
-
- $timesTwo = function ($value) {
- return $value * 2;
- };
- $showSpanish = function ($digit, $spanishNum) {
- return ("The number $digit is called $spanishNum in Spanish");
- };
-
- $mapSpanish = function ($digit, $spanishNum) {
- return (array($digit => $spanishNum));
- };
-
- $callbackOne = function ($a) {
- return array($a);
- };
-
- $callbackTwo = function ($a, $b) {
- return array($a, $b);
- };
-
- $a = array(1, 2, 3, 4, 5);
- $b = array("uno", "dos", "tres", "cuatro", "cinco");
- $c = array("one", "two", "three", "four", "five");
-
- $arrayObjectArray = new ArrayObjectArray($a);
-
- $this->assertSame(array_map($cube, $a), $arrayObjectArray->array_map($cube));
- $arrayObjectArray->exchangeArray(range(1, 5));
- $this->assertSame(array_map($timesTwo, range(1, 5)), $arrayObjectArray->array_map($timesTwo));
- $arrayObjectArray->exchangeArray($a);
- $this->assertSame(array_map($showSpanish, $a, $b), $arrayObjectArray->array_map($showSpanish, $b));
- $this->assertSame(array_map($mapSpanish, $a, $b), $arrayObjectArray->array_map($mapSpanish, $b));
- $this->assertSame(array_map(null, $a, $b, $c), $arrayObjectArray->array_map(null, $b, $c));
- $arrayObjectArray->exchangeArray($this->workingArray);
- $this->assertSame(array_map($callbackOne, $this->workingArray), $arrayObjectArray->array_map($callbackOne));
- $this->assertSame(array_map($callbackTwo, $this->workingArray, $this->workingArray), $arrayObjectArray->array_map($callbackTwo, $this->workingArray));
- $this->assertSame(array_map(null, $this->workingArray), $arrayObjectArray->array_map(null));
- $this->assertSame(array_map(null, $this->workingArray, $this->workingArray), $arrayObjectArray->array_map(null, $this->workingArray));
- }
-
- /**
- * @expectedException \BadMethodCallException
- */
- public function testException()
- {
- $this->arrayObjectArray->error();
- }
-}