Fixed PSR-2

This commit is contained in:
Eric Wheeler 2015-10-23 14:14:29 -07:00
parent 42b5da2e39
commit f61ff02693
2 changed files with 41 additions and 31 deletions

View File

@ -5,7 +5,6 @@
namespace Sikofitt\Hathor\Command; namespace Sikofitt\Hathor\Command;
use Symfony\Component\Finder\Finder; use Symfony\Component\Finder\Finder;
use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Input\InputOption;
@ -15,14 +14,15 @@ use Symfony\Component\Console\Helper\ProgressBar;
use Symfony\Component\Console\Command\Command as BaseCommand; use Symfony\Component\Console\Command\Command as BaseCommand;
use Sikofitt\Hathor\Common\Music\ID3; use Sikofitt\Hathor\Common\Music\ID3;
class ScannerCommand extends BaseCommand { class ScannerCommand extends BaseCommand
{
protected function configure() protected function configure()
{ {
$this $this
->setName('scan') ->setName('scan')
->setDescription('Scans Music') ->setDescription('Scans Music')
->addArgument('file',InputArgument::OPTIONAL, 'the file to work on'); ->addArgument('file', InputArgument::OPTIONAL, 'the file to work on');
} }
protected function execute(InputInterface $input, OutputInterface $output) protected function execute(InputInterface $input, OutputInterface $output)
@ -44,7 +44,7 @@ class ScannerCommand extends BaseCommand {
$progress = new ProgressBar($output, $finder->count()); $progress = new ProgressBar($output, $finder->count());
$progress->setFormat("debug"); $progress->setFormat("debug");
$progress->start(); $progress->start();
foreach($finder as $file) { foreach ($finder as $file) {
$progress->setOverwrite(true); $progress->setOverwrite(true);
$progress->setMessage($file->getFilename()); $progress->setMessage($file->getFilename());
$progress->advance(); $progress->advance();
@ -54,5 +54,4 @@ class ScannerCommand extends BaseCommand {
//$getID3->setFile($input->getArgument('file'))->getFileData()->dumpAll(); //$getID3->setFile($input->getArgument('file'))->getFileData()->dumpAll();
} }
}
}

View File

@ -5,7 +5,6 @@
namespace Sikofitt\Hathor\Common\Music; namespace Sikofitt\Hathor\Common\Music;
use Symfony\Component\VarDumper\VarDumper; use Symfony\Component\VarDumper\VarDumper;
class ID3 extends \getID3 class ID3 extends \getID3
@ -19,15 +18,16 @@ class ID3 extends \getID3
const IS_VORBIS = 3; const IS_VORBIS = 3;
const IS_UNKNOWN = 4; const IS_UNKNOWN = 4;
public function __construct($file = null) { public function __construct($file = null)
{
parent::__construct(); parent::__construct();
if(!is_null($file)) if (!is_null($file)) {
{
$this->file = $file; $this->file = $file;
} }
} }
public function setFile($file) { public function setFile($file)
{
$this->file = $file; $this->file = $file;
return $this; return $this;
} }
@ -35,37 +35,43 @@ class ID3 extends \getID3
/** /**
* @return null * @return null
*/ */
public function getFile() { public function getFile()
{
return $this->file ?: $this->file; return $this->file ?: $this->file;
} }
public function getFileData() { public function getFileData()
{
$this->fileData = $this->analyze($this->getFile()); $this->fileData = $this->analyze($this->getFile());
if(isset($this->fileData['error'])) if (isset($this->fileData['error'])) {
{
throw new \RuntimeException(implode(' ', $this->fileData['error'])); throw new \RuntimeException(implode(' ', $this->fileData['error']));
} else { } else {
return $this; return $this;
} }
} }
public function extractV2() { public function extractV2()
{
return [ return [
]; ];
} }
public function extractV1() { public function extractV1()
{
} }
public function extractAsf() { public function extractAsf()
{
} }
public function extractVorbis() { public function extractVorbis()
{
} }
public function extractDefaultData() { public function extractDefaultData()
switch($this->typeOfTag()) { {
switch ($this->typeOfTag()) {
case $this::IS_ID3V2: case $this::IS_ID3V2:
break; break;
case $this::IS_ID3V1: case $this::IS_ID3V1:
@ -80,13 +86,14 @@ class ID3 extends \getID3
break; break;
} }
} }
public function typeOfTag() { public function typeOfTag()
{
if($this->hasId3v2()) { if ($this->hasId3v2()) {
return $this::IS_ID3V2; return $this::IS_ID3V2;
} elseif($this->hasId3v1()) { } elseif ($this->hasId3v1()) {
return $this::IS_ID3V1; return $this::IS_ID3V1;
} elseif($this->isAsf()) { } elseif ($this->isAsf()) {
return $this::IS_ASF; return $this::IS_ASF;
} else { } else {
return $this::IS_UNKNOWN; return $this::IS_UNKNOWN;
@ -96,29 +103,33 @@ class ID3 extends \getID3
/** /**
* @return bool * @return bool
*/ */
public function hasId3v2() { public function hasId3v2()
{
return isset($this->fileData['id3v2']); return isset($this->fileData['id3v2']);
} }
/** /**
* @return bool * @return bool
*/ */
public function hasId3v1() { public function hasId3v1()
{
return isset($this->fileData['id3v1']); return isset($this->fileData['id3v1']);
} }
/** /**
* @return bool * @return bool
*/ */
public function isAsf() { public function isAsf()
{
return isset($this->fileData['asf']); return isset($this->fileData['asf']);
} }
/** /**
* @return null * @return null
*/ */
public function dumpAll() { public function dumpAll()
if(isset($this->fileData)) { {
if (isset($this->fileData)) {
unset($this->fileData['tags']); unset($this->fileData['tags']);
unset($this->fileData['asf']); unset($this->fileData['asf']);
VarDumper::dump($this->fileData); VarDumper::dump($this->fileData);
@ -126,4 +137,4 @@ class ID3 extends \getID3
return null; return null;
} }
} }
} }