Skip to content

Commit

Permalink
Merge pull request #5 from mmoreram/feature/refactoring-best-practices
Browse files Browse the repository at this point in the history
Some refactoring for using Best Practices
  • Loading branch information
mmoreram committed Oct 29, 2014
2 parents 0d8ac05 + 1913430 commit c7d3318
Show file tree
Hide file tree
Showing 29 changed files with 217 additions and 26 deletions.
2 changes: 1 addition & 1 deletion .formatter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use-sort:
sort-type: alph
sort-direction: asc
header: |
/**
/*
* This file is part of the Extractor package.
*
* For the full copyright and license information, please view the LICENSE
Expand Down
4 changes: 3 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@
"ext-zip": "For usage of Zip adapter"
},
"autoload": {
"psr-4": {"Mmoreram\\Extractor\\": ""}
"psr-4": {
"Mmoreram\\Extractor\\": "src/Extractor"
}
},
"minimum-stability": "stable",
"extra": {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

/**
/*
* This file is part of the Extractor package.
*
* For the full copyright and license information, please view the LICENSE
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

/**
/*
* This file is part of the Extractor package.
*
* For the full copyright and license information, please view the LICENSE
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

/**
/*
* This file is part of the Extractor package.
*
* For the full copyright and license information, please view the LICENSE
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

/**
/*
* This file is part of the Extractor package.
*
* For the full copyright and license information, please view the LICENSE
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

/**
/*
* This file is part of the Extractor package.
*
* For the full copyright and license information, please view the LICENSE
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

/**
/*
* This file is part of the Extractor package.
*
* For the full copyright and license information, please view the LICENSE
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

/**
/*
* This file is part of the Extractor package.
*
* For the full copyright and license information, please view the LICENSE
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

/**
/*
* This file is part of the Extractor package.
*
* For the full copyright and license information, please view the LICENSE
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

/**
/*
* This file is part of the Extractor package.
*
* For the full copyright and license information, please view the LICENSE
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

/**
/*
* This file is part of the Extractor package.
*
* For the full copyright and license information, please view the LICENSE
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

/**
/*
* This file is part of the Extractor package.
*
* For the full copyright and license information, please view the LICENSE
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

/**
/*
* This file is part of the Extractor package.
*
* For the full copyright and license information, please view the LICENSE
Expand Down
2 changes: 1 addition & 1 deletion Extractor.php → src/Extractor/Extractor.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

/**
/*
* This file is part of the Extractor package.
*
* For the full copyright and license information, please view the LICENSE
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

/**
/*
* This file is part of the Extractor package.
*
* For the full copyright and license information, please view the LICENSE
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

/**
/*
* This file is part of the Extractor package.
*
* For the full copyright and license information, please view the LICENSE
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

/**
/*
* This file is part of the Extractor package.
*
* For the full copyright and license information, please view the LICENSE
Expand Down
69 changes: 69 additions & 0 deletions src/Extractor/Resolver/ExtensionResolver.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
<?php

/*
* This file is part of the Extractor package.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* Feel free to edit as you please, and have fun.
*
* @author Marc Morera <[email protected]>
*/

namespace Mmoreram\Extractor\Resolver;

use Mmoreram\Extractor\Exception\ExtensionNotSupportedException;
use Mmoreram\Extractor\Resolver\Interfaces\ExtensionResolverInterface;

/**
* Class ExtensionResolver
*/
class ExtensionResolver implements ExtensionResolverInterface
{
/**
* Return a extractor adapter namespace given an extension
*
* @param string $fileExtension File extension
*
* @return string Adapter namespace
*
* @throws ExtensionNotSupportedException Exception not found
*/
public function getAdapterNamespaceGivenExtension($fileExtension)
{
$adapterNamespace = '\Mmoreram\Extractor\Adapter\\';

switch ($fileExtension) {

case 'zip':
$adapterNamespace .= 'ZipExtractorAdapter';
break;

case 'rar':
$adapterNamespace .= 'RarExtractorAdapter';
break;

case 'phar':
$adapterNamespace .= 'PharExtractorAdapter';
break;

case 'tar':
$adapterNamespace .= 'TarExtractorAdapter';
break;

case 'gz':
$adapterNamespace .= 'TarGzExtractorAdapter';
break;

case 'bz2':
$adapterNamespace .= 'TarBz2ExtractorAdapter';
break;

default:
throw new ExtensionNotSupportedException($fileExtension);
}

return $adapterNamespace;
}
}
33 changes: 33 additions & 0 deletions src/Extractor/Resolver/Interfaces/ExtensionResolverInterface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?php

/*
* This file is part of the Extractor package.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* Feel free to edit as you please, and have fun.
*
* @author Marc Morera <[email protected]>
*/

namespace Mmoreram\Extractor\Resolver\Interfaces;

use Mmoreram\Extractor\Exception\ExtensionNotSupportedException;

/**
* Interface ExtensionResolverInterface
*/
interface ExtensionResolverInterface
{
/**
* Return a extractor adapter namespace given an extension
*
* @param string $fileExtension File extension
*
* @return string Adapter namespace
*
* @throws ExtensionNotSupportedException Exception not found
*/
public function getAdapterNamespaceGivenExtension($fileExtension);
}
2 changes: 1 addition & 1 deletion tests/Adapter/PharExtractorAdapterTest.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

/**
/*
* This file is part of the Extractor package.
*
* For the full copyright and license information, please view the LICENSE
Expand Down
2 changes: 1 addition & 1 deletion tests/Adapter/RarExtractorAdapterTest.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

/**
/*
* This file is part of the Extractor package.
*
* For the full copyright and license information, please view the LICENSE
Expand Down
2 changes: 1 addition & 1 deletion tests/Adapter/TarBz2ExtractorAdapterTest.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

/**
/*
* This file is part of the Extractor package.
*
* For the full copyright and license information, please view the LICENSE
Expand Down
2 changes: 1 addition & 1 deletion tests/Adapter/TarExtractorAdapterTest.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

/**
/*
* This file is part of the Extractor package.
*
* For the full copyright and license information, please view the LICENSE
Expand Down
2 changes: 1 addition & 1 deletion tests/Adapter/TarGzExtractorAdapterTest.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

/**
/*
* This file is part of the Extractor package.
*
* For the full copyright and license information, please view the LICENSE
Expand Down
2 changes: 1 addition & 1 deletion tests/Adapter/ZipExtractorAdapterTest.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

/**
/*
* This file is part of the Extractor package.
*
* For the full copyright and license information, please view the LICENSE
Expand Down
2 changes: 1 addition & 1 deletion tests/ExtractorTest.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

/**
/*
* This file is part of the Extractor package.
*
* For the full copyright and license information, please view the LICENSE
Expand Down
2 changes: 1 addition & 1 deletion tests/Filesystem/SpecificDirectoryTest.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

/**
/*
* This file is part of the Extractor package.
*
* For the full copyright and license information, please view the LICENSE
Expand Down
Loading

0 comments on commit c7d3318

Please sign in to comment.