- adding search method
- resoling an issue
This commit is contained in:
18
src/Ary.php
18
src/Ary.php
@ -88,10 +88,8 @@ class Ary extends \ArrayObject implements \ArrayAccess, \Countable, \IteratorAgg
|
||||
public function &get($key, $default = null)
|
||||
{
|
||||
if ($this->offsetExists($key)) {
|
||||
|
||||
return $this[$key];
|
||||
return $this->getArrayCopy()[$key];
|
||||
}
|
||||
|
||||
return $default;
|
||||
}
|
||||
|
||||
@ -195,4 +193,18 @@ class Ary extends \ArrayObject implements \ArrayAccess, \Countable, \IteratorAgg
|
||||
return (object)$this->all();
|
||||
}
|
||||
|
||||
/**
|
||||
* Search the ary for a given value and return the corresponding key if successful.
|
||||
*
|
||||
* @param mixed $value
|
||||
* @param bool $strict
|
||||
* @return mixed
|
||||
*/
|
||||
public function search($value, $strict = false)
|
||||
{
|
||||
return array_search($value, $this->getArrayCopy(), $strict);
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -6,9 +6,10 @@
|
||||
* Date: 2015/10/15
|
||||
* Time: 11:12 AM
|
||||
*/
|
||||
use salarmehr\ary;
|
||||
|
||||
require '..\src\Ary.php';
|
||||
use \Salarmehr\Ary;
|
||||
|
||||
require __DIR__ . '/../src/Ary.php';
|
||||
|
||||
class Test extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
|
Reference in New Issue
Block a user