From 671b0f3d736eb3fc6f17125f0c879d8ba74b34ab Mon Sep 17 00:00:00 2001 From: Benjamin Perche Date: Fri, 4 Jul 2014 10:01:29 +0200 Subject: [PATCH] =?UTF-8?q?Fix=20cs=20=09modifi=C3=A9:=20=20=20=20=20=20?= =?UTF-8?q?=20=20=20core/lib/Thelia/Core/FileFormat/Archive/AbstractArchiv?= =?UTF-8?q?eBuilder.php=20=09modifi=C3=A9:=20=20=20=20=20=20=20=20=20core/?= =?UTF-8?q?lib/Thelia/Core/FileFormat/Archive/ArchiveBuilder/Exception/Tar?= =?UTF-8?q?ArchiveException.php=20=09modifi=C3=A9:=20=20=20=20=20=20=20=20?= =?UTF-8?q?=20core/lib/Thelia/Core/FileFormat/Archive/ArchiveBuilder/Excep?= =?UTF-8?q?tion/ZipArchiveException.php=20=09modifi=C3=A9:=20=20=20=20=20?= =?UTF-8?q?=20=20=20=20core/lib/Thelia/Core/FileFormat/Archive/ArchiveBuil?= =?UTF-8?q?der/TarArchiveBuilder.php=20=09modifi=C3=A9:=20=20=20=20=20=20?= =?UTF-8?q?=20=20=20core/lib/Thelia/Core/FileFormat/Archive/ArchiveBuilder?= =?UTF-8?q?/TarBz2ArchiveBuilder.php=20=09modifi=C3=A9:=20=20=20=20=20=20?= =?UTF-8?q?=20=20=20core/lib/Thelia/Core/FileFormat/Archive/ArchiveBuilder?= =?UTF-8?q?/TarGzArchiveBuilder.php=20=09modifi=C3=A9:=20=20=20=20=20=20?= =?UTF-8?q?=20=20=20core/lib/Thelia/Core/FileFormat/Archive/ArchiveBuilder?= =?UTF-8?q?/ZipArchiveBuilder.php=20=09modifi=C3=A9:=20=20=20=20=20=20=20?= =?UTF-8?q?=20=20core/lib/Thelia/Core/FileFormat/Archive/ArchiveBuilderInt?= =?UTF-8?q?erface.php=20=09modifi=C3=A9:=20=20=20=20=20=20=20=20=20core/li?= =?UTF-8?q?b/Thelia/Core/FileFormat/Archive/ArchiveBuilderManager.php=20?= =?UTF-8?q?=09modifi=C3=A9:=20=20=20=20=20=20=20=20=20core/lib/Thelia/Core?= =?UTF-8?q?/FileFormat/FormatInterface.php=20=09modifi=C3=A9:=20=20=20=20?= =?UTF-8?q?=20=20=20=20=20core/lib/Thelia/Core/FileFormat/Formatter/Abstra?= =?UTF-8?q?ctFormatter.php=20=09modifi=C3=A9:=20=20=20=20=20=20=20=20=20co?= =?UTF-8?q?re/lib/Thelia/Core/FileFormat/Formatter/Exception/BadFormattedS?= =?UTF-8?q?tringException.php=20=09nouveau=20fichier:=20core/lib/Thelia/Co?= =?UTF-8?q?re/FileFormat/Formatter/FormatterData.php=20=09nouveau=20fichie?= =?UTF-8?q?r:=20core/lib/Thelia/Core/FileFormat/Formatter/FormatterInterfa?= =?UTF-8?q?ce.php=20=09modifi=C3=A9:=20=20=20=20=20=20=20=20=20core/lib/Th?= =?UTF-8?q?elia/Core/FileFormat/Formatter/FormatterManager.php=20=09modifi?= =?UTF-8?q?=C3=A9:=20=20=20=20=20=20=20=20=20core/lib/Thelia/Tests/FileFor?= =?UTF-8?q?mat/Archive/ArchiveBuilder/TarArchiveBuilderTest.php=20=09modif?= =?UTF-8?q?i=C3=A9:=20=20=20=20=20=20=20=20=20core/lib/Thelia/Tests/FileFo?= =?UTF-8?q?rmat/Archive/ArchiveBuilder/TarBz2ArchiveBuilderTest.php=20=09m?= =?UTF-8?q?odifi=C3=A9:=20=20=20=20=20=20=20=20=20core/lib/Thelia/Tests/Fi?= =?UTF-8?q?leFormat/Archive/ArchiveBuilder/TarGzArchiveBuilderTest.php=20?= =?UTF-8?q?=09modifi=C3=A9:=20=20=20=20=20=20=20=20=20core/lib/Thelia/Test?= =?UTF-8?q?s/FileFormat/Archive/ArchiveBuilder/ZipArchiveBuilderTest.php?= =?UTF-8?q?=20=09modifi=C3=A9:=20=20=20=20=20=20=20=20=20core/lib/Thelia/T?= =?UTF-8?q?ests/FileFormat/Archive/ArchiveBuilderManagerTest.php=20=09modi?= =?UTF-8?q?fi=C3=A9:=20=20=20=20=20=20=20=20=20core/lib/Thelia/Tests/FileF?= =?UTF-8?q?ormat/Formatter/FormatterManagerTest.php=20=09modifi=C3=A9:=20?= =?UTF-8?q?=20=20=20=20=20=20=20=20core/lib/Thelia/Tests/Tools/FakeFileDow?= =?UTF-8?q?nloader.php=20=09modifi=C3=A9:=20=20=20=20=20=20=20=20=20core/l?= =?UTF-8?q?ib/Thelia/Tests/Tools/FileDownloaderTest.php?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Archive/AbstractArchiveBuilder.php | 4 +- .../Exception/TarArchiveException.php | 2 +- .../Exception/ZipArchiveException.php | 2 +- .../ArchiveBuilder/TarArchiveBuilder.php | 50 +++++++++---------- .../ArchiveBuilder/TarBz2ArchiveBuilder.php | 2 +- .../ArchiveBuilder/TarGzArchiveBuilder.php | 2 +- .../ArchiveBuilder/ZipArchiveBuilder.php | 40 ++++++++------- .../Archive/ArchiveBuilderInterface.php | 21 ++++---- .../Archive/ArchiveBuilderManager.php | 4 +- .../Core/FileFormat/FormatInterface.php | 2 +- .../Formatter/AbstractFormatter.php | 21 +------- .../Exception/BadFormattedStringException.php | 2 +- .../FileFormat/Formatter/FormatterData.php | 23 +++++++++ .../Formatter/FormatterInterface.php | 39 +++++++++++++++ .../FileFormat/Formatter/FormatterManager.php | 4 +- .../ArchiveBuilder/TarArchiveBuilderTest.php | 4 +- .../TarBz2ArchiveBuilderTest.php | 2 +- .../TarGzArchiveBuilderTest.php | 3 +- .../ArchiveBuilder/ZipArchiveBuilderTest.php | 2 +- .../Archive/ArchiveBuilderManagerTest.php | 2 +- .../Formatter/FormatterManagerTest.php | 2 +- .../Thelia/Tests/Tools/FakeFileDownloader.php | 6 +-- .../Thelia/Tests/Tools/FileDownloaderTest.php | 2 +- 23 files changed, 142 insertions(+), 99 deletions(-) create mode 100644 core/lib/Thelia/Core/FileFormat/Formatter/FormatterData.php create mode 100644 core/lib/Thelia/Core/FileFormat/Formatter/FormatterInterface.php diff --git a/core/lib/Thelia/Core/FileFormat/Archive/AbstractArchiveBuilder.php b/core/lib/Thelia/Core/FileFormat/Archive/AbstractArchiveBuilder.php index aa6e2ccad..e873d74ef 100644 --- a/core/lib/Thelia/Core/FileFormat/Archive/AbstractArchiveBuilder.php +++ b/core/lib/Thelia/Core/FileFormat/Archive/AbstractArchiveBuilder.php @@ -201,7 +201,7 @@ abstract class AbstractArchiveBuilder implements FormatInterface, ArchiveBuilder } /** - * @param string $environment + * @param string $environment * @return $this * * Sets the execution environment of the Kernel, @@ -211,4 +211,4 @@ abstract class AbstractArchiveBuilder implements FormatInterface, ArchiveBuilder { $this->environment = $environment; } -} \ No newline at end of file +} diff --git a/core/lib/Thelia/Core/FileFormat/Archive/ArchiveBuilder/Exception/TarArchiveException.php b/core/lib/Thelia/Core/FileFormat/Archive/ArchiveBuilder/Exception/TarArchiveException.php index 9945a65be..3e2d583d6 100644 --- a/core/lib/Thelia/Core/FileFormat/Archive/ArchiveBuilder/Exception/TarArchiveException.php +++ b/core/lib/Thelia/Core/FileFormat/Archive/ArchiveBuilder/Exception/TarArchiveException.php @@ -20,4 +20,4 @@ namespace Thelia\Core\FileFormat\Archive\ArchiveBuilder\Exception; class TarArchiveException extends \Exception { -} \ No newline at end of file +} diff --git a/core/lib/Thelia/Core/FileFormat/Archive/ArchiveBuilder/Exception/ZipArchiveException.php b/core/lib/Thelia/Core/FileFormat/Archive/ArchiveBuilder/Exception/ZipArchiveException.php index 24f9ddb37..f69375dec 100644 --- a/core/lib/Thelia/Core/FileFormat/Archive/ArchiveBuilder/Exception/ZipArchiveException.php +++ b/core/lib/Thelia/Core/FileFormat/Archive/ArchiveBuilder/Exception/ZipArchiveException.php @@ -20,4 +20,4 @@ namespace Thelia\Core\FileFormat\Archive\ArchiveBuilder\Exception; class ZipArchiveException extends \ErrorException { -} \ No newline at end of file +} diff --git a/core/lib/Thelia/Core/FileFormat/Archive/ArchiveBuilder/TarArchiveBuilder.php b/core/lib/Thelia/Core/FileFormat/Archive/ArchiveBuilder/TarArchiveBuilder.php index 6d9db55fd..0f2cd67c7 100644 --- a/core/lib/Thelia/Core/FileFormat/Archive/ArchiveBuilder/TarArchiveBuilder.php +++ b/core/lib/Thelia/Core/FileFormat/Archive/ArchiveBuilder/TarArchiveBuilder.php @@ -57,10 +57,10 @@ class TarArchiveBuilder extends AbstractArchiveBuilder } /** - * @param string $filePath It is the path to access the file. - * @param string $directoryInArchive This is the directory where it will be stored in the archive - * @param null|string $name The name of the file in the archive. if it null or empty, it keeps the same name - * @param bool $isOnline + * @param string $filePath It is the path to access the file. + * @param string $directoryInArchive This is the directory where it will be stored in the archive + * @param null|string $name The name of the file in the archive. if it null or empty, it keeps the same name + * @param bool $isOnline * @return $this * @throws \Thelia\Exception\FileNotFoundException * @throws \Thelia\Exception\FileNotReadableException @@ -107,7 +107,7 @@ class TarArchiveBuilder extends AbstractArchiveBuilder /** * @param $content * @param $name - * @param string $directoryInArchive + * @param string $directoryInArchive * @return mixed * @throws \ErrorException * @@ -132,7 +132,7 @@ class TarArchiveBuilder extends AbstractArchiveBuilder } try { $this->tar->addFromString($name, $content); - } catch(\Exception $e) { + } catch (\Exception $e) { throw new \ErrorException( $this->translator->trans( "Error while writing the file into the archive, error message: %errmes", @@ -144,7 +144,6 @@ class TarArchiveBuilder extends AbstractArchiveBuilder } } - /** * @param $directoryPath * @return $this @@ -160,7 +159,7 @@ class TarArchiveBuilder extends AbstractArchiveBuilder try { $this->tar->addEmptyDir($directoryInArchive); - } catch(\Exception $e) { + } catch (\Exception $e) { throw new \ErrorException( $this->translator->trans( "The directory %dir has not been created in the archive", @@ -176,7 +175,7 @@ class TarArchiveBuilder extends AbstractArchiveBuilder } /** - * @param string $pathToFile + * @param string $pathToFile * @return null|string * @throws \Thelia\Exception\FileNotFoundException * @throws \Thelia\Exception\FileNotReadableException @@ -206,7 +205,6 @@ class TarArchiveBuilder extends AbstractArchiveBuilder return $content; } - /** * @param $pathInArchive * @return $this @@ -269,10 +267,10 @@ class TarArchiveBuilder extends AbstractArchiveBuilder } /** - * @param string $pathToArchive - * @param string $environment - * @param bool $isOnline - * @param FileDownloaderInterface $fileDownloader + * @param string $pathToArchive + * @param string $environment + * @param bool $isOnline + * @param FileDownloaderInterface $fileDownloader * @return $this * @throws \Thelia\Exception\FileNotFoundException * @throws \Thelia\Exception\HttpUrlException @@ -292,6 +290,7 @@ class TarArchiveBuilder extends AbstractArchiveBuilder * This throws TarArchiveBuilderException if * the archive is not valid. */ + return $tar->setEnvironment($tar->environment); } @@ -312,19 +311,19 @@ class TarArchiveBuilder extends AbstractArchiveBuilder /** @var \PharFileInfo $fileInfo */ $fileInfo = $this->tar[$pathToFile]; - if($fileInfo->isFile()) { + if ($fileInfo->isFile()) { $isFile = true; } /** * Catch the exception to avoid its displaying. */ - } catch(\BadMethodCallException $e) {} + } catch (\BadMethodCallException $e) {} return $isFile; } /** - * @param string $directory + * @param string $directory * @return bool * * Check if the archive has a directory @@ -338,19 +337,19 @@ class TarArchiveBuilder extends AbstractArchiveBuilder /** @var \PharFileInfo $fileInfo */ $fileInfo = $this->tar[$pathToDir]; - if($fileInfo->isDir()) { + if ($fileInfo->isDir()) { $isDir = true; } /** * Catch the exception to avoid its displaying. */ - } catch(\BadMethodCallException $e) {} + } catch (\BadMethodCallException $e) {} return $isDir; } /** - * @param string $environment + * @param string $environment * @return $this * * Sets the execution environment of the Kernel, @@ -383,13 +382,12 @@ class TarArchiveBuilder extends AbstractArchiveBuilder $this->compressionEntryPoint(); - - } catch(\BadMethodCallException $e) { + } catch (\BadMethodCallException $e) { /** * This should not happen */ $errorMessage = "You have badly called the method setEnvironment twice for %file"; - } catch(\UnexpectedValueException $e) { + } catch (\UnexpectedValueException $e) { $errorMessage = "The file %file is corrupted"; } @@ -411,7 +409,7 @@ class TarArchiveBuilder extends AbstractArchiveBuilder } /** - * @param string $initialString + * @param string $initialString * @return string * * Gives a valid file path for \ZipArchive @@ -432,7 +430,7 @@ class TarArchiveBuilder extends AbstractArchiveBuilder } /** - * @param string $initialString + * @param string $initialString * @return string * * Gives a valid directory path for \ZipArchive @@ -496,4 +494,4 @@ class TarArchiveBuilder extends AbstractArchiveBuilder { return $this->compression; } -} \ No newline at end of file +} diff --git a/core/lib/Thelia/Core/FileFormat/Archive/ArchiveBuilder/TarBz2ArchiveBuilder.php b/core/lib/Thelia/Core/FileFormat/Archive/ArchiveBuilder/TarBz2ArchiveBuilder.php index bd85d8599..774d082df 100644 --- a/core/lib/Thelia/Core/FileFormat/Archive/ArchiveBuilder/TarBz2ArchiveBuilder.php +++ b/core/lib/Thelia/Core/FileFormat/Archive/ArchiveBuilder/TarBz2ArchiveBuilder.php @@ -44,4 +44,4 @@ class TarBz2ArchiveBuilder extends TarArchiveBuilder return $this; } -} \ No newline at end of file +} diff --git a/core/lib/Thelia/Core/FileFormat/Archive/ArchiveBuilder/TarGzArchiveBuilder.php b/core/lib/Thelia/Core/FileFormat/Archive/ArchiveBuilder/TarGzArchiveBuilder.php index 33c16aba9..4722417fa 100644 --- a/core/lib/Thelia/Core/FileFormat/Archive/ArchiveBuilder/TarGzArchiveBuilder.php +++ b/core/lib/Thelia/Core/FileFormat/Archive/ArchiveBuilder/TarGzArchiveBuilder.php @@ -49,4 +49,4 @@ class TarGzArchiveBuilder extends TarArchiveBuilder return $this; } -} \ No newline at end of file +} diff --git a/core/lib/Thelia/Core/FileFormat/Archive/ArchiveBuilder/ZipArchiveBuilder.php b/core/lib/Thelia/Core/FileFormat/Archive/ArchiveBuilder/ZipArchiveBuilder.php index 85ee78da8..fd49b5c87 100644 --- a/core/lib/Thelia/Core/FileFormat/Archive/ArchiveBuilder/ZipArchiveBuilder.php +++ b/core/lib/Thelia/Core/FileFormat/Archive/ArchiveBuilder/ZipArchiveBuilder.php @@ -47,7 +47,7 @@ class ZipArchiveBuilder extends AbstractArchiveBuilder * On the destruction of the class, * remove the temporary file. */ - function __destruct() + public function __destruct() { if ($this->zip instanceof \ZipArchive) { @$this->zip->close(); @@ -59,10 +59,10 @@ class ZipArchiveBuilder extends AbstractArchiveBuilder } /** - * @param string $filePath It is the path to access the file. - * @param string $directoryInArchive This is the directory where it will be stored in the archive - * @param null|string $name The name of the file in the archive. if it null or empty, it keeps the same name - * @param bool $isOnline + * @param string $filePath It is the path to access the file. + * @param string $directoryInArchive This is the directory where it will be stored in the archive + * @param null|string $name The name of the file in the archive. if it null or empty, it keeps the same name + * @param bool $isOnline * @return $this * @throws \Thelia\Exception\FileNotFoundException * @throws \Thelia\Exception\FileNotReadableException @@ -80,7 +80,7 @@ class ZipArchiveBuilder extends AbstractArchiveBuilder * Add empty directory if it doesn't exist */ - if(!empty($directoryInArchive)) { + if (!empty($directoryInArchive)) { $this->addDirectory($directoryInArchive); } @@ -127,7 +127,7 @@ class ZipArchiveBuilder extends AbstractArchiveBuilder /** * @param $content * @param $name - * @param string $directoryInArchive + * @param string $directoryInArchive * @return mixed * @throws \ErrorException * @@ -194,7 +194,7 @@ class ZipArchiveBuilder extends AbstractArchiveBuilder } /** - * @param string $pathToFile + * @param string $pathToFile * @return null|string * @throws \Thelia\Exception\FileNotFoundException * @throws \Thelia\Exception\FileNotReadableException @@ -224,7 +224,7 @@ class ZipArchiveBuilder extends AbstractArchiveBuilder /** - * @param string $initialString + * @param string $initialString * @return string * * Gives a valid file path for \ZipArchive @@ -244,11 +244,12 @@ class ZipArchiveBuilder extends AbstractArchiveBuilder if (preg_match("#\/?[^\/]+\/[^\/]+\/?#", $initialString)) { $initialString = "/" . $initialString; } + return $initialString; } /** - * @param string $initialString + * @param string $initialString * @return string * * Gives a valid directory path for \ZipArchive @@ -336,9 +337,9 @@ class ZipArchiveBuilder extends AbstractArchiveBuilder } /** - * @param string $pathToArchive - * @param bool $isOnline - * @param FileDownloaderInterface $fileDownloader + * @param string $pathToArchive + * @param bool $isOnline + * @param FileDownloaderInterface $fileDownloader * @return ZipArchiveBuilder * @throws \Thelia\Exception\FileNotFoundException * @throws \Thelia\Exception\HttpUrlException @@ -383,7 +384,7 @@ class ZipArchiveBuilder extends AbstractArchiveBuilder } /** - * @param string $directory + * @param string $directory * @return bool * * Checks if the link $directory exists and if it's not a file. @@ -396,7 +397,7 @@ class ZipArchiveBuilder extends AbstractArchiveBuilder } /** - * @param string $environment + * @param string $environment * @return $this * * Sets the execution environment of the Kernel, @@ -417,7 +418,7 @@ class ZipArchiveBuilder extends AbstractArchiveBuilder \ZipArchive::CREATE ); - if($opening !== true) { + if ($opening !== true) { throw new \ErrorException( $this->translator->trans( "An unknown error append" @@ -511,7 +512,7 @@ class ZipArchiveBuilder extends AbstractArchiveBuilder } /** - * @param string $initialString + * @param string $initialString * @return string * * Gives a valid file path for \ZipArchive @@ -531,11 +532,12 @@ class ZipArchiveBuilder extends AbstractArchiveBuilder if (preg_match("#\/?[^\/]+\/[^/]+\/?#", $initialString)) { $initialString = "/" . $initialString; } + return $initialString; } /** - * @param string $initialString + * @param string $initialString * @return string * * Gives a valid directory path for \ZipArchive @@ -598,4 +600,4 @@ class ZipArchiveBuilder extends AbstractArchiveBuilder { return $this->zip; } -} \ No newline at end of file +} diff --git a/core/lib/Thelia/Core/FileFormat/Archive/ArchiveBuilderInterface.php b/core/lib/Thelia/Core/FileFormat/Archive/ArchiveBuilderInterface.php index c8166779b..ab37760ca 100644 --- a/core/lib/Thelia/Core/FileFormat/Archive/ArchiveBuilderInterface.php +++ b/core/lib/Thelia/Core/FileFormat/Archive/ArchiveBuilderInterface.php @@ -12,7 +12,6 @@ namespace Thelia\Core\FileFormat\Archive; - /** * Interface ArchiveBuilderInterface * @package Thelia\Core\FileFormat\Archive @@ -23,10 +22,10 @@ namespace Thelia\Core\FileFormat\Archive; interface ArchiveBuilderInterface { /** - * @param string $filePath It is the path to access the file. - * @param string $directoryInArchive This is the directory where it will be stored in the archive - * @param null|string $name The name of the file in the archive. if it null or empty, it keeps the same name - * @param bool $isOnline + * @param string $filePath It is the path to access the file. + * @param string $directoryInArchive This is the directory where it will be stored in the archive + * @param null|string $name The name of the file in the archive. if it null or empty, it keeps the same name + * @param bool $isOnline * @return $this * @throws \Thelia\Exception\FileNotFoundException * @throws \Thelia\Exception\FileNotReadableException @@ -41,7 +40,7 @@ interface ArchiveBuilderInterface /** * @param $content * @param $name - * @param string $directoryInArchive + * @param string $directoryInArchive * @return mixed * @throws \ErrorException * @@ -50,7 +49,7 @@ interface ArchiveBuilderInterface public function addFileFromString($content, $name, $directoryInArchive = "/"); /** - * @param string $pathToFile + * @param string $pathToFile * @return null|string * @throws \Thelia\Exception\FileNotFoundException * @throws \Thelia\Exception\FileNotReadableException @@ -85,8 +84,8 @@ interface ArchiveBuilderInterface public function buildArchiveResponse(); /** - * @param string $pathToArchive - * @param bool $isOnline + * @param string $pathToArchive + * @param bool $isOnline * @return $this * @throws \Thelia\Exception\FileNotFoundException * @throws \Thelia\Exception\HttpUrlException @@ -104,11 +103,11 @@ interface ArchiveBuilderInterface public function hasFile($pathToFile); /** - * @param string $directory + * @param string $directory * @return bool * * Check if the archive has a directory */ public function hasDirectory($directory); -} \ No newline at end of file +} diff --git a/core/lib/Thelia/Core/FileFormat/Archive/ArchiveBuilderManager.php b/core/lib/Thelia/Core/FileFormat/Archive/ArchiveBuilderManager.php index 7957fca4f..21e0fe338 100644 --- a/core/lib/Thelia/Core/FileFormat/Archive/ArchiveBuilderManager.php +++ b/core/lib/Thelia/Core/FileFormat/Archive/ArchiveBuilderManager.php @@ -29,7 +29,7 @@ class ArchiveBuilderManager $this->environment = $environment; } /** - * @param AbstractArchiveBuilder $archiveCreator + * @param AbstractArchiveBuilder $archiveCreator * @return $this */ public function add(AbstractArchiveBuilder $archiveCreator) @@ -73,4 +73,4 @@ class ArchiveBuilderManager { return $this->archiveCreators; } -} \ No newline at end of file +} diff --git a/core/lib/Thelia/Core/FileFormat/FormatInterface.php b/core/lib/Thelia/Core/FileFormat/FormatInterface.php index cd10a0cb0..4b327271d 100644 --- a/core/lib/Thelia/Core/FileFormat/FormatInterface.php +++ b/core/lib/Thelia/Core/FileFormat/FormatInterface.php @@ -55,4 +55,4 @@ interface FormatInterface * return "application/json"; */ public function getMimeType(); -} \ No newline at end of file +} diff --git a/core/lib/Thelia/Core/FileFormat/Formatter/AbstractFormatter.php b/core/lib/Thelia/Core/FileFormat/Formatter/AbstractFormatter.php index f991535c8..605bc6362 100644 --- a/core/lib/Thelia/Core/FileFormat/Formatter/AbstractFormatter.php +++ b/core/lib/Thelia/Core/FileFormat/Formatter/AbstractFormatter.php @@ -18,24 +18,7 @@ use Thelia\Core\FileFormat\FormatInterface; * @package Thelia\Core\FileFormat\Formatter * @author Benjamin Perche */ -abstract class AbstractFormatter implements FormatInterface +abstract class AbstractFormatter implements FormatInterface, FormatterInterface { - /** - * @param array $data - * @return mixed - * - * Encodes an array to the desired format. - * $data array only contains array and scalar data. - */ - abstract public function encode(array $data); - /** - * @param $data - * @return array - * @throws \Thelia\Core\FileFormat\Formatter\Exception\BadFormattedStringException - * - * this method must do exactly the opposite of encode and return - * an array composed of array and scalar data. - */ - abstract public function decode($data); -} \ No newline at end of file +} diff --git a/core/lib/Thelia/Core/FileFormat/Formatter/Exception/BadFormattedStringException.php b/core/lib/Thelia/Core/FileFormat/Formatter/Exception/BadFormattedStringException.php index 6d763a01b..18d28bb78 100644 --- a/core/lib/Thelia/Core/FileFormat/Formatter/Exception/BadFormattedStringException.php +++ b/core/lib/Thelia/Core/FileFormat/Formatter/Exception/BadFormattedStringException.php @@ -20,4 +20,4 @@ namespace Thelia\Core\FileFormat\Formatter\Exception; class BadFormattedStringException extends \ErrorException { -} \ No newline at end of file +} diff --git a/core/lib/Thelia/Core/FileFormat/Formatter/FormatterData.php b/core/lib/Thelia/Core/FileFormat/Formatter/FormatterData.php new file mode 100644 index 000000000..689ad0ba6 --- /dev/null +++ b/core/lib/Thelia/Core/FileFormat/Formatter/FormatterData.php @@ -0,0 +1,23 @@ + + */ +class FormatterData +{ + +} diff --git a/core/lib/Thelia/Core/FileFormat/Formatter/FormatterInterface.php b/core/lib/Thelia/Core/FileFormat/Formatter/FormatterInterface.php new file mode 100644 index 000000000..4d2d2d91e --- /dev/null +++ b/core/lib/Thelia/Core/FileFormat/Formatter/FormatterInterface.php @@ -0,0 +1,39 @@ + + */ +interface FormatterInterface +{ + /** + * @param FormatterData $data + * @return mixed + * + * This method must use a FormatterData object and output + * a formatted value. + */ + public function encode(FormatterData $data); + + /** + * @param $rawData + * @return FormatterData + * + * This must takes raw data as argument and outputs + * a FormatterData object. + */ + public function decode($rawData); +} diff --git a/core/lib/Thelia/Core/FileFormat/Formatter/FormatterManager.php b/core/lib/Thelia/Core/FileFormat/Formatter/FormatterManager.php index cc8aad8e4..b8e5d5d66 100644 --- a/core/lib/Thelia/Core/FileFormat/Formatter/FormatterManager.php +++ b/core/lib/Thelia/Core/FileFormat/Formatter/FormatterManager.php @@ -18,7 +18,7 @@ use Thelia\Core\Translation\Translator; * @package Thelia\Core\FileFormat\Formatter * @author Benjamin Perche */ -class FormatterManager +class FormatterManager { protected $formatters = array(); @@ -66,4 +66,4 @@ class FormatterManager { return $this->formatters; } -} \ No newline at end of file +} diff --git a/core/lib/Thelia/Tests/FileFormat/Archive/ArchiveBuilder/TarArchiveBuilderTest.php b/core/lib/Thelia/Tests/FileFormat/Archive/ArchiveBuilder/TarArchiveBuilderTest.php index fe8728d14..e34acdf76 100644 --- a/core/lib/Thelia/Tests/FileFormat/Archive/ArchiveBuilder/TarArchiveBuilderTest.php +++ b/core/lib/Thelia/Tests/FileFormat/Archive/ArchiveBuilder/TarArchiveBuilderTest.php @@ -227,7 +227,7 @@ class TarArchiveBuilderTest extends \PHPUnit_Framework_TestCase $this->tar->formatDirectoryPath("//foo/bar///baz/") ); } - + public function testFormatFilePath() { $this->assertEquals( @@ -288,4 +288,4 @@ class TarArchiveBuilderTest extends \PHPUnit_Framework_TestCase $this->tar->getCompression() ); } -} \ No newline at end of file +} diff --git a/core/lib/Thelia/Tests/FileFormat/Archive/ArchiveBuilder/TarBz2ArchiveBuilderTest.php b/core/lib/Thelia/Tests/FileFormat/Archive/ArchiveBuilder/TarBz2ArchiveBuilderTest.php index f968bf759..a65892424 100644 --- a/core/lib/Thelia/Tests/FileFormat/Archive/ArchiveBuilder/TarBz2ArchiveBuilderTest.php +++ b/core/lib/Thelia/Tests/FileFormat/Archive/ArchiveBuilder/TarBz2ArchiveBuilderTest.php @@ -35,4 +35,4 @@ class TarBz2ArchiveBuilderTest extends TarArchiveBuilderTest $this->tar->getCompression() ); } -} \ No newline at end of file +} diff --git a/core/lib/Thelia/Tests/FileFormat/Archive/ArchiveBuilder/TarGzArchiveBuilderTest.php b/core/lib/Thelia/Tests/FileFormat/Archive/ArchiveBuilder/TarGzArchiveBuilderTest.php index e70ea33ee..5b1aded6e 100644 --- a/core/lib/Thelia/Tests/FileFormat/Archive/ArchiveBuilder/TarGzArchiveBuilderTest.php +++ b/core/lib/Thelia/Tests/FileFormat/Archive/ArchiveBuilder/TarGzArchiveBuilderTest.php @@ -12,7 +12,6 @@ namespace Thelia\Tests\FileFormat\Archive\ArchiveBuilder; use Thelia\Core\FileFormat\Archive\ArchiveBuilder\TarGzArchiveBuilder; -use Thelia\Core\HttpFoundation\Response; /** * Class TarGzArchiveBuilderTest @@ -36,4 +35,4 @@ class TarGzArchiveBuilderTest extends TarArchiveBuilderTest $this->tar->getCompression() ); } -} \ No newline at end of file +} diff --git a/core/lib/Thelia/Tests/FileFormat/Archive/ArchiveBuilder/ZipArchiveBuilderTest.php b/core/lib/Thelia/Tests/FileFormat/Archive/ArchiveBuilder/ZipArchiveBuilderTest.php index bc3560694..c3b039bd4 100644 --- a/core/lib/Thelia/Tests/FileFormat/Archive/ArchiveBuilder/ZipArchiveBuilderTest.php +++ b/core/lib/Thelia/Tests/FileFormat/Archive/ArchiveBuilder/ZipArchiveBuilderTest.php @@ -395,4 +395,4 @@ class ZipArchiveBuilderTest extends \PHPUnit_Framework_TestCase ); } -} \ No newline at end of file +} diff --git a/core/lib/Thelia/Tests/FileFormat/Archive/ArchiveBuilderManagerTest.php b/core/lib/Thelia/Tests/FileFormat/Archive/ArchiveBuilderManagerTest.php index c01b35a45..69fdfdb9a 100644 --- a/core/lib/Thelia/Tests/FileFormat/Archive/ArchiveBuilderManagerTest.php +++ b/core/lib/Thelia/Tests/FileFormat/Archive/ArchiveBuilderManagerTest.php @@ -72,4 +72,4 @@ class ArchiveBuilderManagerTest extends \PHPUnit_Framework_TestCase $this->manager->delete("foo"); } -} \ No newline at end of file +} diff --git a/core/lib/Thelia/Tests/FileFormat/Formatter/FormatterManagerTest.php b/core/lib/Thelia/Tests/FileFormat/Formatter/FormatterManagerTest.php index 8759c2fca..39bf06cb3 100644 --- a/core/lib/Thelia/Tests/FileFormat/Formatter/FormatterManagerTest.php +++ b/core/lib/Thelia/Tests/FileFormat/Formatter/FormatterManagerTest.php @@ -71,4 +71,4 @@ class FormatterManagerTest extends \PHPUnit_Framework_TestCase { $this->manager->delete("foo"); } -} \ No newline at end of file +} diff --git a/core/lib/Thelia/Tests/Tools/FakeFileDownloader.php b/core/lib/Thelia/Tests/Tools/FakeFileDownloader.php index 851036062..a45a3b8ec 100644 --- a/core/lib/Thelia/Tests/Tools/FakeFileDownloader.php +++ b/core/lib/Thelia/Tests/Tools/FakeFileDownloader.php @@ -22,8 +22,8 @@ use Thelia\Tools\FileDownload\FileDownloader; class FakeFileDownloader extends FileDownloader { /** - * @param string $url - * @param string $pathToStore + * @param string $url + * @param string $pathToStore * @throws \Thelia\Exception\FileNotFoundException * @throws \ErrorException * @throws \HttpUrlException @@ -41,4 +41,4 @@ class FakeFileDownloader extends FileDownloader } } -} \ No newline at end of file +} diff --git a/core/lib/Thelia/Tests/Tools/FileDownloaderTest.php b/core/lib/Thelia/Tests/Tools/FileDownloaderTest.php index 7bc36523f..e62840494 100644 --- a/core/lib/Thelia/Tests/Tools/FileDownloaderTest.php +++ b/core/lib/Thelia/Tests/Tools/FileDownloaderTest.php @@ -60,4 +60,4 @@ class FileDownloaderTest extends \PHPUnit_Framework_TestCase { $this->downloader->download("https://github.com/thelia/thelia", "php://temp"); } -} \ No newline at end of file +}