- extending Illuminate\Support\Collection so its method is available in ary.

- checking php version before defining the ary() helper function.
This commit is contained in:
Reza
2016-03-04 13:37:21 +03:30
parent 3b5f90fe46
commit 97e02abf76
4 changed files with 21 additions and 9 deletions

View File

@ -10,7 +10,8 @@
}
],
"require": {
"php": ">=5.4.0"
"php": ">=5.4.0",
"illuminate/support": "*"
},
"autoload": {
"psr-4": {

View File

@ -14,10 +14,11 @@ use ArrayAccess;
use ArrayIterator;
use CachingIterator;
use Countable;
use Illuminate\Support\Collection;
use IteratorAggregate;
use JsonSerializable;
class Ary implements ArrayAccess, Countable, IteratorAggregate, JsonSerializable
class Ary extends Collection implements ArrayAccess, Countable, IteratorAggregate, JsonSerializable
{
/**

View File

@ -7,8 +7,16 @@
use Salarmehr\Ary;
if (!function_exists('ary')) {
if (!function_exists('ary') && phpversion()) {
function parse_version($version)
{
$version = explode('.', $version);
return $version[0] * 10000 + $version[1] * 100 + $version[2];
}
if (!defined('ary') && parse_version(PHP_VERSION) > parse_version('5.6.0')) {
/**
* @param mixed $items,...
* @return Ary
@ -18,4 +26,5 @@ if (!function_exists('ary')) {
return new Ary(...func_get_args());
}
}
}

View File

@ -9,6 +9,7 @@
use \Salarmehr\Ary;
require __DIR__ . '/../vendor/autoload.php';
require __DIR__ . '/../src/Ary.php';
class Test extends PHPUnit_Framework_TestCase