- 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:
@ -10,7 +10,8 @@
|
||||
}
|
||||
],
|
||||
"require": {
|
||||
"php": ">=5.4.0"
|
||||
"php": ">=5.4.0",
|
||||
"illuminate/support": "*"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
|
@ -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
|
||||
{
|
||||
|
||||
/**
|
||||
|
@ -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
|
||||
@ -17,5 +25,6 @@ if (!function_exists('ary')) {
|
||||
{
|
||||
return new Ary(...func_get_args());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -9,6 +9,7 @@
|
||||
|
||||
use \Salarmehr\Ary;
|
||||
|
||||
require __DIR__ . '/../vendor/autoload.php';
|
||||
require __DIR__ . '/../src/Ary.php';
|
||||
|
||||
class Test extends PHPUnit_Framework_TestCase
|
||||
|
Reference in New Issue
Block a user