Use latest fix
This commit is contained in:
parent
92121bb804
commit
0736141e16
3 changed files with 22 additions and 33 deletions
|
|
@ -37,18 +37,14 @@ abstract class AbstractData implements \Countable
|
|||
* Returns the property value given its name.
|
||||
*
|
||||
* @param string $property
|
||||
* @param mixed $default [optional]
|
||||
* @return mixed
|
||||
* @param mixed $default
|
||||
*
|
||||
* @throws InvalidArgumentException In case the data does not have the property
|
||||
* @return mixed
|
||||
*/
|
||||
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));
|
||||
return $default;
|
||||
}
|
||||
|
||||
return $this->properties[$property];
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ class Stream extends AbstractData
|
|||
*/
|
||||
public function isAudio()
|
||||
{
|
||||
return $this->has('codec_type') ? 'audio' === $this->get('codec_type') : false;
|
||||
return $this->get('codec_type') === 'audio';
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -34,7 +34,7 @@ class Stream extends AbstractData
|
|||
*/
|
||||
public function isVideo()
|
||||
{
|
||||
return $this->has('codec_type') ? 'video' === $this->get('codec_type') : false;
|
||||
return $this->get('codec_type') === 'video';
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -51,14 +51,11 @@ class Stream extends AbstractData
|
|||
throw new LogicException('Dimensions can only be retrieved from video streams.');
|
||||
}
|
||||
|
||||
$width = $height = $sampleRatio = $displayRatio = null;
|
||||
$sampleRatio = $displayRatio = null;
|
||||
|
||||
$width = $this->get('width');
|
||||
$height = $this->get('height');
|
||||
|
||||
if ($this->has('width')) {
|
||||
$width = $this->get('width');
|
||||
}
|
||||
if ($this->has('height')) {
|
||||
$height = $this->get('height');
|
||||
}
|
||||
if (null !== $ratio = $this->extractRatio($this, 'sample_aspect_ratio')) {
|
||||
$sampleRatio = $ratio;
|
||||
}
|
||||
|
|
@ -93,18 +90,18 @@ class Stream extends AbstractData
|
|||
*/
|
||||
private function extractRatio(Stream $stream, $name)
|
||||
{
|
||||
if ($stream->has($name)) {
|
||||
$ratio = $stream->get($name);
|
||||
if (preg_match('/\d+:\d+/', $ratio)) {
|
||||
$data = array_filter(explode(':', $ratio), function ($int) {
|
||||
return $int > 0;
|
||||
});
|
||||
if (2 === count($data)) {
|
||||
return array_map(function ($int) { return (int) $int; }, $data);
|
||||
}
|
||||
}
|
||||
if (!$stream->has($name)) {
|
||||
return;
|
||||
}
|
||||
|
||||
return null;
|
||||
$ratio = $stream->get($name);
|
||||
if (preg_match('/\d+:\d+/', $ratio)) {
|
||||
$data = array_filter(explode(':', $ratio), function ($int) {
|
||||
return $int > 0;
|
||||
});
|
||||
if (2 === count($data)) {
|
||||
return array_map(function ($int) { return (int) $int; }, $data);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,14 +25,10 @@ class AbstractDataTest extends TestCase
|
|||
$this->assertEquals('value2', $imp->get('key2'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException FFMpeg\Exception\InvalidArgumentException
|
||||
*/
|
||||
public function testGetInvalid()
|
||||
public function testGetDefault()
|
||||
{
|
||||
$imp = new Implementation(array('key1' => 'value1', 'key2' => 'value2'));
|
||||
|
||||
$imp->get('key3');
|
||||
$this->assertSame('yololo', $imp->get('key3', 'yololo'));
|
||||
}
|
||||
|
||||
public function testKeys()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue