-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5 from mmoreram/feature/refactoring-best-practices
Some refactoring for using Best Practices
- Loading branch information
Showing
29 changed files
with
217 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...er/Abstracts/AbstractExtractorAdapter.php → ...er/Abstracts/AbstractExtractorAdapter.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
Adapter/DummyExtractorAdapter.php → ...tractor/Adapter/DummyExtractorAdapter.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
.../Interfaces/ExtractorAdapterInterface.php → .../Interfaces/ExtractorAdapterInterface.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
Adapter/PharExtractorAdapter.php → ...xtractor/Adapter/PharExtractorAdapter.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
Adapter/RarExtractorAdapter.php → ...Extractor/Adapter/RarExtractorAdapter.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
Adapter/TarBz2ExtractorAdapter.php → ...ractor/Adapter/TarBz2ExtractorAdapter.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
Adapter/TarExtractorAdapter.php → ...Extractor/Adapter/TarExtractorAdapter.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
Adapter/TarGzExtractorAdapter.php → ...tractor/Adapter/TarGzExtractorAdapter.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
Adapter/ZipExtractorAdapter.php → ...Extractor/Adapter/ZipExtractorAdapter.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
Exception/AdapterNotAvailableException.php → ...xception/AdapterNotAvailableException.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
Exception/ExtensionNotSupportedException.php → ...eption/ExtensionNotSupportedException.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
Exception/FileNotFoundException.php → ...actor/Exception/FileNotFoundException.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
Filesystem/Interfaces/DirectoryInterface.php → ...esystem/Interfaces/DirectoryInterface.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
Filesystem/SpecificDirectory.php → ...xtractor/Filesystem/SpecificDirectory.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
Filesystem/TemporaryDirectory.php → ...tractor/Filesystem/TemporaryDirectory.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
33
src/Extractor/Resolver/Interfaces/ExtensionResolverInterface.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.