From 7bbd06876c1a01fe82f9b25a7e0f86168bc36ac4 Mon Sep 17 00:00:00 2001 From: sujayjaju Date: Thu, 13 Nov 2014 12:40:39 +0530 Subject: [PATCH] Update AbstractData.php Ability to set default return values when a property is not available in the probe results --- src/FFMpeg/FFProbe/DataMapping/AbstractData.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/FFMpeg/FFProbe/DataMapping/AbstractData.php b/src/FFMpeg/FFProbe/DataMapping/AbstractData.php index 6fee9e2..adfbd67 100644 --- a/src/FFMpeg/FFProbe/DataMapping/AbstractData.php +++ b/src/FFMpeg/FFProbe/DataMapping/AbstractData.php @@ -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)); }