Skip to content

Commit

Permalink
[spl] add get method to array object. with default option.
Browse files Browse the repository at this point in the history
  • Loading branch information
makasim committed Mar 4, 2016
1 parent 911813c commit ae14864
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions Bridge/Spl/ArrayObject.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,17 @@ public function __construct($input = array(), $flags = 0, $iterator_class = "Arr
parent::__construct($input, $flags, $iterator_class);
}

/**
* @param string $key
* @param mixed $default
*
* @return mixed
*/
public function get($key, $default = null)
{
return array_key_exists($key, $this->input) ? $this->input[$key] : $default;
}

/**
* @param array|\Traversable $input
*
Expand Down

0 comments on commit ae14864

Please sign in to comment.