Update AbstractData.php

Ability to set default return values when a property is not available in the probe results
This commit is contained in:
sujayjaju 2014-11-13 12:40:39 +05:30
commit 7bbd06876c

View file

@ -37,13 +37,17 @@ abstract class AbstractData implements \Countable
* Returns the property value given its name.
*
* @param string $property
* @param mixed $default [optional]
* @return mixed
*
* @throws InvalidArgumentException In case the data does not have the property
*/
public function get($property)
public function get($property, $default = null)
{
if (!isset($this->properties[$property])) {
if(!is_null($default)){
return $default;
}
throw new InvalidArgumentException(sprintf('Invalid property `%s`.', $property));
}