- 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": {
|
"require": {
|
||||||
"php": ">=5.4.0"
|
"php": ">=5.4.0",
|
||||||
|
"illuminate/support": "*"
|
||||||
},
|
},
|
||||||
"autoload": {
|
"autoload": {
|
||||||
"psr-4": {
|
"psr-4": {
|
||||||
|
@ -14,10 +14,11 @@ use ArrayAccess;
|
|||||||
use ArrayIterator;
|
use ArrayIterator;
|
||||||
use CachingIterator;
|
use CachingIterator;
|
||||||
use Countable;
|
use Countable;
|
||||||
|
use Illuminate\Support\Collection;
|
||||||
use IteratorAggregate;
|
use IteratorAggregate;
|
||||||
use JsonSerializable;
|
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;
|
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,...
|
* @param mixed $items,...
|
||||||
* @return Ary
|
* @return Ary
|
||||||
@ -18,4 +26,5 @@ if (!function_exists('ary')) {
|
|||||||
return new Ary(...func_get_args());
|
return new Ary(...func_get_args());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@ -9,6 +9,7 @@
|
|||||||
|
|
||||||
use \Salarmehr\Ary;
|
use \Salarmehr\Ary;
|
||||||
|
|
||||||
|
require __DIR__ . '/../vendor/autoload.php';
|
||||||
require __DIR__ . '/../src/Ary.php';
|
require __DIR__ . '/../src/Ary.php';
|
||||||
|
|
||||||
class Test extends PHPUnit_Framework_TestCase
|
class Test extends PHPUnit_Framework_TestCase
|
||||||
|
Reference in New Issue
Block a user