Compare commits

...

1 Commits
master ... 0.1

Author SHA1 Message Date
R. Eric Wheeler 7f645f3002 added array_pop and non array_* functions 2016-07-22 14:35:40 -07:00
4 changed files with 895 additions and 685 deletions

View File

@ -33,5 +33,10 @@
"Sikofitt\\Tests\\": "tests/Sikofitt/Tests/"
}
},
"extra":{
"branch-alias": {
"dev-master": "0.1"
}
},
"minimum-stability": "stable"
}

262
composer.lock generated
View File

@ -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": "e783c69d217d2ee4cd8d84375554030d",
"content-hash": "a03a3e83bc124fad42d5a75c770dc38a",
"hash": "7a143d2b80a8fbc2a3a2ba8f3a471dcc",
"content-hash": "a5f532508427f4bca1f34f14b1aa4688",
"packages": [
{
"name": "ircmaxell/password-compat",
@ -424,38 +424,87 @@
"time": "2015-03-18 18:23:50"
},
{
"name": "phpdocumentor/reflection-docblock",
"version": "2.0.4",
"name": "phpdocumentor/reflection-common",
"version": "1.0",
"source": {
"type": "git",
"url": "https://github.com/phpDocumentor/ReflectionDocBlock.git",
"reference": "d68dbdc53dc358a816f00b300704702b2eaff7b8"
"url": "https://github.com/phpDocumentor/ReflectionCommon.git",
"reference": "144c307535e82c8fdcaacbcfc1d6d8eeb896687c"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/d68dbdc53dc358a816f00b300704702b2eaff7b8",
"reference": "d68dbdc53dc358a816f00b300704702b2eaff7b8",
"url": "https://api.github.com/repos/phpDocumentor/ReflectionCommon/zipball/144c307535e82c8fdcaacbcfc1d6d8eeb896687c",
"reference": "144c307535e82c8fdcaacbcfc1d6d8eeb896687c",
"shasum": ""
},
"require": {
"php": ">=5.3.3"
"php": ">=5.5"
},
"require-dev": {
"phpunit/phpunit": "~4.0"
},
"suggest": {
"dflydev/markdown": "~1.0",
"erusev/parsedown": "~1.0"
"phpunit/phpunit": "^4.6"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "2.0.x-dev"
"dev-master": "1.0.x-dev"
}
},
"autoload": {
"psr-0": {
"phpDocumentor": [
"psr-4": {
"phpDocumentor\\Reflection\\": [
"src"
]
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Jaap van Otterdijk",
"email": "opensource@ijaap.nl"
}
],
"description": "Common reflection classes used by phpdocumentor to reflect the code structure",
"homepage": "http://www.phpdoc.org",
"keywords": [
"FQSEN",
"phpDocumentor",
"phpdoc",
"reflection",
"static analysis"
],
"time": "2015-12-27 11:43:31"
},
{
"name": "phpdocumentor/reflection-docblock",
"version": "3.1.0",
"source": {
"type": "git",
"url": "https://github.com/phpDocumentor/ReflectionDocBlock.git",
"reference": "9270140b940ff02e58ec577c237274e92cd40cdd"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/9270140b940ff02e58ec577c237274e92cd40cdd",
"reference": "9270140b940ff02e58ec577c237274e92cd40cdd",
"shasum": ""
},
"require": {
"php": ">=5.5",
"phpdocumentor/reflection-common": "^1.0@dev",
"phpdocumentor/type-resolver": "^0.2.0",
"webmozart/assert": "^1.0"
},
"require-dev": {
"mockery/mockery": "^0.9.4",
"phpunit/phpunit": "^4.4"
},
"type": "library",
"autoload": {
"psr-4": {
"phpDocumentor\\Reflection\\": [
"src/"
]
}
@ -467,10 +516,58 @@
"authors": [
{
"name": "Mike van Riel",
"email": "mike.vanriel@naenius.com"
"email": "me@mikevanriel.com"
}
],
"time": "2015-02-03 12:10:50"
"description": "With this component, a library can provide support for annotations via DocBlocks or otherwise retrieve information that is embedded in a DocBlock.",
"time": "2016-06-10 09:48:41"
},
{
"name": "phpdocumentor/type-resolver",
"version": "0.2",
"source": {
"type": "git",
"url": "https://github.com/phpDocumentor/TypeResolver.git",
"reference": "b39c7a5b194f9ed7bd0dd345c751007a41862443"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/phpDocumentor/TypeResolver/zipball/b39c7a5b194f9ed7bd0dd345c751007a41862443",
"reference": "b39c7a5b194f9ed7bd0dd345c751007a41862443",
"shasum": ""
},
"require": {
"php": ">=5.5",
"phpdocumentor/reflection-common": "^1.0"
},
"require-dev": {
"mockery/mockery": "^0.9.4",
"phpunit/phpunit": "^5.2||^4.8.24"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.0.x-dev"
}
},
"autoload": {
"psr-4": {
"phpDocumentor\\Reflection\\": [
"src/"
]
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Mike van Riel",
"email": "me@mikevanriel.com"
}
],
"time": "2016-06-10 07:14:17"
},
{
"name": "phpspec/prophecy",
@ -1375,21 +1472,21 @@
},
{
"name": "symfony/config",
"version": "v2.8.8",
"version": "v3.1.2",
"source": {
"type": "git",
"url": "https://github.com/symfony/config.git",
"reference": "0926e69411eba491803dbafb9f1f233e2ced58d0"
"reference": "bcf5aebabc95b56e370e13d78565f74c7d8726dc"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/config/zipball/0926e69411eba491803dbafb9f1f233e2ced58d0",
"reference": "0926e69411eba491803dbafb9f1f233e2ced58d0",
"url": "https://api.github.com/repos/symfony/config/zipball/bcf5aebabc95b56e370e13d78565f74c7d8726dc",
"reference": "bcf5aebabc95b56e370e13d78565f74c7d8726dc",
"shasum": ""
},
"require": {
"php": ">=5.3.9",
"symfony/filesystem": "~2.3|~3.0.0"
"php": ">=5.5.9",
"symfony/filesystem": "~2.8|~3.0"
},
"suggest": {
"symfony/yaml": "To use the yaml reference dumper"
@ -1397,7 +1494,7 @@
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "2.8-dev"
"dev-master": "3.1-dev"
}
},
"autoload": {
@ -1424,30 +1521,30 @@
],
"description": "Symfony Config Component",
"homepage": "https://symfony.com",
"time": "2016-06-29 05:31:50"
"time": "2016-06-29 05:41:56"
},
{
"name": "symfony/console",
"version": "v2.8.8",
"version": "v3.1.2",
"source": {
"type": "git",
"url": "https://github.com/symfony/console.git",
"reference": "c392a6ec72f2122748032c2ad6870420561ffcfa"
"reference": "747154aa69b0f83cd02fc9aa554836dee417631a"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/console/zipball/c392a6ec72f2122748032c2ad6870420561ffcfa",
"reference": "c392a6ec72f2122748032c2ad6870420561ffcfa",
"url": "https://api.github.com/repos/symfony/console/zipball/747154aa69b0f83cd02fc9aa554836dee417631a",
"reference": "747154aa69b0f83cd02fc9aa554836dee417631a",
"shasum": ""
},
"require": {
"php": ">=5.3.9",
"php": ">=5.5.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"
"symfony/event-dispatcher": "~2.8|~3.0",
"symfony/process": "~2.8|~3.0"
},
"suggest": {
"psr/log": "For using the console logger",
@ -1457,7 +1554,7 @@
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "2.8-dev"
"dev-master": "3.1-dev"
}
},
"autoload": {
@ -1484,7 +1581,7 @@
],
"description": "Symfony Console Component",
"homepage": "https://symfony.com",
"time": "2016-06-29 07:02:14"
"time": "2016-06-29 07:02:31"
},
{
"name": "symfony/event-dispatcher",
@ -1548,25 +1645,25 @@
},
{
"name": "symfony/filesystem",
"version": "v2.8.8",
"version": "v3.1.2",
"source": {
"type": "git",
"url": "https://github.com/symfony/filesystem.git",
"reference": "7258ddd6f987053f21fa43d03430580ba54e6096"
"reference": "322da5f0910d8aa0b25fa65ffccaba68dbddb890"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/filesystem/zipball/7258ddd6f987053f21fa43d03430580ba54e6096",
"reference": "7258ddd6f987053f21fa43d03430580ba54e6096",
"url": "https://api.github.com/repos/symfony/filesystem/zipball/322da5f0910d8aa0b25fa65ffccaba68dbddb890",
"reference": "322da5f0910d8aa0b25fa65ffccaba68dbddb890",
"shasum": ""
},
"require": {
"php": ">=5.3.9"
"php": ">=5.5.9"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "2.8-dev"
"dev-master": "3.1-dev"
}
},
"autoload": {
@ -1593,7 +1690,7 @@
],
"description": "Symfony Filesystem Component",
"homepage": "https://symfony.com",
"time": "2016-06-29 05:31:50"
"time": "2016-06-29 05:41:56"
},
{
"name": "symfony/polyfill-mbstring",
@ -1656,25 +1753,25 @@
},
{
"name": "symfony/stopwatch",
"version": "v2.8.8",
"version": "v3.1.2",
"source": {
"type": "git",
"url": "https://github.com/symfony/stopwatch.git",
"reference": "35bae476693150728b0eb51647faac82faf9aaca"
"reference": "bb42806b12c5f89db4ebf64af6741afe6d8457e1"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/stopwatch/zipball/35bae476693150728b0eb51647faac82faf9aaca",
"reference": "35bae476693150728b0eb51647faac82faf9aaca",
"url": "https://api.github.com/repos/symfony/stopwatch/zipball/bb42806b12c5f89db4ebf64af6741afe6d8457e1",
"reference": "bb42806b12c5f89db4ebf64af6741afe6d8457e1",
"shasum": ""
},
"require": {
"php": ">=5.3.9"
"php": ">=5.5.9"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "2.8-dev"
"dev-master": "3.1-dev"
}
},
"autoload": {
@ -1701,29 +1798,29 @@
],
"description": "Symfony Stopwatch Component",
"homepage": "https://symfony.com",
"time": "2016-06-29 05:29:29"
"time": "2016-06-29 05:41:56"
},
{
"name": "symfony/yaml",
"version": "v2.8.8",
"version": "v3.1.2",
"source": {
"type": "git",
"url": "https://github.com/symfony/yaml.git",
"reference": "dba4bb5846798cd12f32e2d8f3f35d77045773c8"
"reference": "2884c26ce4c1d61aebf423a8b912950fe7c764de"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/yaml/zipball/dba4bb5846798cd12f32e2d8f3f35d77045773c8",
"reference": "dba4bb5846798cd12f32e2d8f3f35d77045773c8",
"url": "https://api.github.com/repos/symfony/yaml/zipball/2884c26ce4c1d61aebf423a8b912950fe7c764de",
"reference": "2884c26ce4c1d61aebf423a8b912950fe7c764de",
"shasum": ""
},
"require": {
"php": ">=5.3.9"
"php": ">=5.5.9"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "2.8-dev"
"dev-master": "3.1-dev"
}
},
"autoload": {
@ -1750,7 +1847,56 @@
],
"description": "Symfony Yaml Component",
"homepage": "https://symfony.com",
"time": "2016-06-29 05:29:29"
"time": "2016-06-29 05:41:56"
},
{
"name": "webmozart/assert",
"version": "1.0.2",
"source": {
"type": "git",
"url": "https://github.com/webmozart/assert.git",
"reference": "30eed06dd6bc88410a4ff7f77b6d22f3ce13dbde"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/webmozart/assert/zipball/30eed06dd6bc88410a4ff7f77b6d22f3ce13dbde",
"reference": "30eed06dd6bc88410a4ff7f77b6d22f3ce13dbde",
"shasum": ""
},
"require": {
"php": ">=5.3.3"
},
"require-dev": {
"phpunit/phpunit": "^4.6"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.0-dev"
}
},
"autoload": {
"psr-4": {
"Webmozart\\Assert\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Bernhard Schussek",
"email": "bschussek@gmail.com"
}
],
"description": "Assertions to validate method input/output with nice error messages.",
"keywords": [
"assert",
"check",
"validate"
],
"time": "2015-08-24 13:29:44"
}
],
"aliases": [],
@ -1759,7 +1905,7 @@
"prefer-stable": false,
"prefer-lowest": false,
"platform": {
"php": ">=5.3.29"
"php": ">=5.3"
},
"platform-dev": []
}

View File

@ -19,17 +19,10 @@ namespace Sikofitt\Utility;
*
* @package Sikofitt\Utility
*/
use Guzzle\Common\Exception\BadMethodCallException;
/**
* Class ArrayObjectArray
*
* @package Sikofitt\Utility
*/
class ArrayObjectArray extends \ArrayObject implements \IteratorAggregate
{
/**
* @var \ArrayIterator
* @var \Iterator
*/
private $iterator;
@ -64,11 +57,14 @@ class ArrayObjectArray extends \ArrayObject implements \IteratorAggregate
}
/**
* Alias of current
*
* @return int
* Current position of the array
*/
public function pos()
{
return pos($this->iterator);
return $this->current();
}
/**
@ -167,11 +163,20 @@ class ArrayObjectArray extends \ArrayObject implements \IteratorAggregate
$argv[0],
$this->getArrayCopy()
);
break;
case 'array_map':
$callback = $argv[0];
array_shift($argv);
return call_user_func_array('array_map', array_merge(array($callback), array($this->getArrayCopy()), $argv));
break;
case 'array_pop':
$arrayCopy = $this->getArrayCopy();
if(null !== $returnValue = array_pop($arrayCopy))
{
$this->exchangeArray($arrayCopy);
}
return $returnValue;
break;
default:
return call_user_func_array(
$function,

View File

@ -26,34 +26,79 @@
* 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
* 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 a
* rray_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_* 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
* 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
*/
class ArrayObjectArrayTest extends \PHPUnit_Framework_TestCase
{
@ -308,8 +353,17 @@
// array_pad
$this->assertSame(array_pad($this->workingArray, 6, 'hello'), $this->arrayObjectArray->array_pad(6, 'hello'));
// array_pop
$data = $this->arrayObjectArrayData();
$arrayObjectArray = new ArrayObjectArray($data['alpha']);
$alpha = $data['alpha'];
$this->assertSame($alpha, $arrayObjectArray->getArrayCopy());
$this->assertSame(array_pop($alpha), $arrayObjectArray->array_pop());
$this->assertSame($alpha, $arrayObjectArray->getArrayCopy());
// array_product
// array_push
// array_rand
// array_reduce