Skip to content

Commit

Permalink
Merge pull request #51 from mhor/analysis-864y1W
Browse files Browse the repository at this point in the history
Applied fixes from StyleCI
  • Loading branch information
mhor committed May 2, 2016
2 parents 54f17be + 52d7e16 commit aaad5e7
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 33 deletions.
8 changes: 4 additions & 4 deletions src/Container/MediaInfoContainer.php
Original file line number Diff line number Diff line change
Expand Up @@ -222,19 +222,19 @@ private function addOther(Other $other)
{
$this->others[] = $other;
}

/**
* Convert the object into array
* Convert the object into array.
*
* @return array
*/
public function jsonSerialize()
{
return get_object_vars($this);
}

/**
* Dump object to array
* Dump object to array.
*
* @return array
*/
Expand Down
12 changes: 5 additions & 7 deletions src/Type/AbstractType.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,28 +34,26 @@ public function get($attribute = null)
if (isset($this->attributes[$attribute])) {
return $this->attributes[$attribute];
}

return;
}

/**
* Convert the object into json
* Convert the object into json.
*
* @return array
*/
public function jsonSerialize()
{
$array = get_object_vars($this);

if (isset($array['attributes'])) {
$array = $array['attributes'];
}

return $array;
}

/**
* Convert the object into array
* Convert the object into array.
*
* @return array
*/
Expand Down
44 changes: 22 additions & 22 deletions test/Container/MediaInfoContainerTest.php
Original file line number Diff line number Diff line change
@@ -1,64 +1,64 @@
<?php

use Mhor\MediaInfo\Container\MediaInfoContainer,
Mhor\MediaInfo\Type\General,
Mhor\MediaInfo\Type\Audio;
use Mhor\MediaInfo\Container\MediaInfoContainer;
use Mhor\MediaInfo\Type\Audio;
use Mhor\MediaInfo\Type\General;

class MediaInfoContainerTest extends \PHPUnit_Framework_TestCase
{
private function createContainer()
{
$mediaInfoContainer = new MediaInfoContainer();

$general = new General();

$general->set('Format', 'MPEG Audio');
$general->set('Duration', '1mn 20s');

$audio = new Audio();

$audio->set('Format', 'MPEG Audio');
$audio->set('Bit rate', '56.0 Kbps');

$mediaInfoContainer->add($audio);
$mediaInfoContainer->add($general);

return $mediaInfoContainer;
}

public function testToJson()
{
$mediaInfoContainer = $this->createContainer();

$data = json_encode($mediaInfoContainer);

$this->assertRegExp('/^\{.+\}$/', $data);
}

public function testToJsonType()
{
$mediaInfoContainer = $this->createContainer();

$data = json_encode($mediaInfoContainer->getGeneral());

$this->assertRegExp('/^\{.+\}$/', $data);
}

public function testToArray()
{
$mediaInfoContainer = $this->createContainer();

$array = $mediaInfoContainer->__toArray();

$this->assertArrayHasKey('version', $array);
}

public function testToArrayType()
{
$mediaInfoContainer = $this->createContainer();

$array = $mediaInfoContainer->getGeneral()->__toArray();

$this->assertTrue(is_array($array));
}
}
}

0 comments on commit aaad5e7

Please sign in to comment.