diff --git a/src/Ary.php b/src/Ary.php index 460074d..3e6918c 100644 --- a/src/Ary.php +++ b/src/Ary.php @@ -11,8 +11,6 @@ namespace Salarmehr; use ArrayAccess; -use ArrayIterator; -use CachingIterator; use Countable; use Illuminate\Support\Collection; use IteratorAggregate; @@ -20,18 +18,10 @@ use JsonSerializable; class Ary extends Collection implements ArrayAccess, Countable, IteratorAggregate, JsonSerializable { - - /** - * The items contained in the collection. - * - * @var array - */ - protected $items = []; - /** * Create a new collection. * - * @param mixed $items + * @param mixed $items */ public function __construct() @@ -46,36 +36,6 @@ class Ary extends Collection implements ArrayAccess, Countable, IteratorAggregat $this->items = $items; } - /** - * Results array of items from Collection or Arrayable. - * - * @param mixed $items - * @return array - */ - protected function getArrayableItems($items) - { - if ($items instanceof self) { - return $items->all(); - } - if (method_exists($items, 'toArray')) { - return $items->toArray(); - } - if ($items instanceof \JsonSerializable) { - return json_decode(json_encode($items), true); - } - return (array)$items; - } - - /** - * Get all of the items in the collection. - * - * @return array - */ - public function all() - { - return $this->items; - } - public function &__get($item) { return $this->get($item); @@ -110,17 +70,6 @@ class Ary extends Collection implements ArrayAccess, Countable, IteratorAggregat return $array; } - /** - * Determine if an item exists at an offset. - * - * @param mixed $key - * @return bool - */ - public function offsetExists($key) - { - return array_key_exists($key, $this->items); - } - /** * Set the item at a given offset. * @@ -167,117 +116,11 @@ class Ary extends Collection implements ArrayAccess, Countable, IteratorAggregat return $this->get($key); } - /** - * Convert the object into something JSON serializable. - * - * @return array - */ - public function jsonSerialize() - { - return $this->all(); - } - - /** - * Get the collection of items as a plain array. - * - * @return array - */ - public function toArray() - { - return $this->all(); - } - - /** - * Merge the collection with the given items. - * - * @param mixed $items - * @return static - */ - public function merge($items) - { - return new static(array_merge($this->items, $this->getArrayableItems($items))); - } - - /** - * Get a CachingIterator instance. - * - * @param int $flags - * @return \CachingIterator - */ - public function getCachingIterator($flags = CachingIterator::CALL_TOSTRING) - { - return new \CachingIterator($this->getIterator(), $flags); - } - - /** - * Get an iterator for the items. - * - * @return \ArrayIterator - */ - public function getIterator() - { - return new ArrayIterator($this->items); - } - - /** - * Count the number of items in the collection. - * - * @return int - */ - public function count() - { - return count($this->items); - } - - /** - * Convert the collection to its string representation. - * - * @return string - */ - - public function __toString() - { - return $this->toJson(); - } - - /** - * Get the collection of items as JSON. - * - * @param int $options - * @return string - */ - public function toJson($options = 0) - { - return json_encode($this->all(), $options); - } - - /** - * Get a subset of the items from the given array. - * - * @param array|string $keys - * @return array - */ - public function only($keys) - { - return array_intersect_key($this->all(), array_flip((array)$keys)); - } - public function __isset($name) { return $this->has($name); } - /** - * Determine if an item exists in the collection by key. - * - * @param mixed $key - * @return bool - */ - public function has($key) - { - return $this->offsetExists($key); - } - /** * Get the collection of items as a plain object. * @@ -289,17 +132,10 @@ class Ary extends Collection implements ArrayAccess, Countable, IteratorAggregat } /** - * Search the ary for a given value and return the corresponding key if successful. - * - * @param mixed $value - * @param bool $strict - * @return mixed + * Return a subset of current ary as a new ary + * @param $item + * @return Ary */ - public function search($value, $strict = false) - { - return array_search($value, $this->items, $strict); - } - public function ary($item) { return new ary($this->get($item)); @@ -309,15 +145,4 @@ class Ary extends Collection implements ArrayAccess, Countable, IteratorAggregat { $this->offsetUnset($key); } - - /** - * Unset the item at a given offset. - * - * @param string $key - * @return void - */ - public function offsetUnset($key) - { - unset($this->items[$key]); - } } \ No newline at end of file