From 2e4987a47cfc7385a82c4a46c20cdb5c46f0024a 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 | 8 ++ .../Exception/TarArchiveException.php | 4 + .../Exception/ZipArchiveException.php | 2 +- .../ArchiveBuilder/TarArchiveBuilder.php | 78 +++++++++++++++++++ .../ArchiveBuilder/TarBz2ArchiveBuilder.php | 4 + .../ArchiveBuilder/TarGzArchiveBuilder.php | 4 + .../ArchiveBuilder/ZipArchiveBuilder.php | 56 ++++++++++++- .../Archive/ArchiveBuilderInterface.php | 28 ++++++- .../Archive/ArchiveBuilderManager.php | 8 ++ .../Core/FileFormat/FormatInterface.php | 4 + .../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 | 6 +- .../TarBz2ArchiveBuilderTest.php | 4 + .../TarGzArchiveBuilderTest.php | 7 ++ .../ArchiveBuilder/ZipArchiveBuilderTest.php | 4 + .../Archive/ArchiveBuilderManagerTest.php | 4 + .../Formatter/FormatterManagerTest.php | 2 +- .../Thelia/Tests/Tools/FakeFileDownloader.php | 9 +++ .../Thelia/Tests/Tools/FileDownloaderTest.php | 4 + 23 files changed, 295 insertions(+), 30 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 5c2acf0d7..18b06931c 100644 --- a/core/lib/Thelia/Core/FileFormat/Archive/AbstractArchiveBuilder.php +++ b/core/lib/Thelia/Core/FileFormat/Archive/AbstractArchiveBuilder.php @@ -258,8 +258,12 @@ abstract class AbstractArchiveBuilder implements FormatInterface, ArchiveBuilder ======= /** +<<<<<<< HEAD * @param string $environment >>>>>>> Finish tar, tar.gz, tar.bz2 and tests +======= + * @param string $environment +>>>>>>> Fix cs * @return $this * * Sets the execution environment of the Kernel, @@ -270,6 +274,7 @@ abstract class AbstractArchiveBuilder implements FormatInterface, ArchiveBuilder $this->environment = $environment; } <<<<<<< HEAD +<<<<<<< HEAD } ======= } @@ -283,3 +288,6 @@ abstract class AbstractArchiveBuilder implements FormatInterface, ArchiveBuilder ======= } >>>>>>> Finish tar, tar.gz, tar.bz2 and tests +======= +} +>>>>>>> Fix cs 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 9566c4eaa..977860947 100644 --- a/core/lib/Thelia/Core/FileFormat/Archive/ArchiveBuilder/Exception/TarArchiveException.php +++ b/core/lib/Thelia/Core/FileFormat/Archive/ArchiveBuilder/Exception/TarArchiveException.php @@ -20,8 +20,12 @@ namespace Thelia\Core\FileFormat\Archive\ArchiveBuilder\Exception; class TarArchiveException extends \Exception { +<<<<<<< HEAD <<<<<<< HEAD } ======= } >>>>>>> Finish implementing and testing zip +======= +} +>>>>>>> Fix cs 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 f61463161..272408b28 100644 --- a/core/lib/Thelia/Core/FileFormat/Archive/ArchiveBuilder/TarArchiveBuilder.php +++ b/core/lib/Thelia/Core/FileFormat/Archive/ArchiveBuilder/TarArchiveBuilder.php @@ -109,6 +109,7 @@ class TarArchiveBuilder extends AbstractArchiveBuilder * @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 +<<<<<<< HEAD ======= }*/ ======= @@ -121,6 +122,8 @@ class TarArchiveBuilder extends AbstractArchiveBuilder * @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 >>>>>>> Finish implementing and testing zip +======= +>>>>>>> Fix cs * @return $this * @throws \Thelia\Exception\FileNotFoundException * @throws \Thelia\Exception\FileNotReadableException @@ -184,11 +187,15 @@ class TarArchiveBuilder extends AbstractArchiveBuilder /** * @param $content * @param $name +<<<<<<< HEAD <<<<<<< HEAD * @param string $directoryInArchive ======= * @param string $directoryInArchive >>>>>>> Finish implementing and testing zip +======= + * @param string $directoryInArchive +>>>>>>> Fix cs * @return mixed * @throws \ErrorException * @@ -213,11 +220,15 @@ class TarArchiveBuilder extends AbstractArchiveBuilder } try { $this->tar->addFromString($name, $content); +<<<<<<< HEAD <<<<<<< HEAD } catch (\Exception $e) { ======= } catch(\Exception $e) { >>>>>>> Finish implementing and testing zip +======= + } catch (\Exception $e) { +>>>>>>> Fix cs throw new \ErrorException( $this->translator->trans( "Error while writing the file into the archive, error message: %errmes", @@ -229,10 +240,13 @@ class TarArchiveBuilder extends AbstractArchiveBuilder } } +<<<<<<< HEAD <<<<<<< HEAD ======= >>>>>>> Finish implementing and testing zip +======= +>>>>>>> Fix cs /** * @param $directoryPath * @return $this @@ -248,11 +262,15 @@ class TarArchiveBuilder extends AbstractArchiveBuilder try { $this->tar->addEmptyDir($directoryInArchive); +<<<<<<< HEAD <<<<<<< HEAD } catch (\Exception $e) { ======= } catch(\Exception $e) { >>>>>>> Finish implementing and testing zip +======= + } catch (\Exception $e) { +>>>>>>> Fix cs throw new \ErrorException( $this->translator->trans( "The directory %dir has not been created in the archive", @@ -268,11 +286,15 @@ class TarArchiveBuilder extends AbstractArchiveBuilder } /** +<<<<<<< HEAD <<<<<<< HEAD * @param string $pathToFile ======= * @param string $pathToFile >>>>>>> Finish implementing and testing zip +======= + * @param string $pathToFile +>>>>>>> Fix cs * @return null|string * @throws \Thelia\Exception\FileNotFoundException * @throws \Thelia\Exception\FileNotReadableException @@ -315,6 +337,7 @@ class TarArchiveBuilder extends AbstractArchiveBuilder return $content; } +<<<<<<< HEAD ======= ======= @@ -324,6 +347,8 @@ class TarArchiveBuilder extends AbstractArchiveBuilder >>>>>>> Finish implementing and testing zip +======= +>>>>>>> Fix cs /** * @param $pathInArchive * @return $this @@ -424,11 +449,18 @@ class TarArchiveBuilder extends AbstractArchiveBuilder } /** +<<<<<<< HEAD * @param string $pathToArchive * @param string $environment * @param bool $isOnline * @param FileDownloaderInterface $fileDownloader >>>>>>> Finish implementing and testing zip +======= + * @param string $pathToArchive + * @param string $environment + * @param bool $isOnline + * @param FileDownloaderInterface $fileDownloader +>>>>>>> Fix cs * @return $this * @throws \Thelia\Exception\FileNotFoundException * @throws \Thelia\Exception\HttpUrlException @@ -483,6 +515,9 @@ class TarArchiveBuilder extends AbstractArchiveBuilder */ <<<<<<< HEAD <<<<<<< HEAD +<<<<<<< HEAD +======= +>>>>>>> Fix cs return $tar->setEnvironment($tar->environment); ======= @@ -512,31 +547,43 @@ class TarArchiveBuilder extends AbstractArchiveBuilder /** @var \PharFileInfo $fileInfo */ $fileInfo = $this->tar[$pathToFile]; +<<<<<<< HEAD <<<<<<< HEAD if ($fileInfo->isFile()) { ======= if($fileInfo->isFile()) { >>>>>>> Finish implementing and testing zip +======= + if ($fileInfo->isFile()) { +>>>>>>> Fix cs $isFile = true; } /** * Catch the exception to avoid its displaying. */ +<<<<<<< HEAD <<<<<<< HEAD } catch (\BadMethodCallException $e) {} ======= } catch(\BadMethodCallException $e) {} >>>>>>> Finish implementing and testing zip +======= + } catch (\BadMethodCallException $e) {} +>>>>>>> Fix cs return $isFile; } /** +<<<<<<< HEAD <<<<<<< HEAD * @param string $directory ======= * @param string $directory >>>>>>> Finish implementing and testing zip +======= + * @param string $directory +>>>>>>> Fix cs * @return bool * * Check if the archive has a directory @@ -550,31 +597,43 @@ class TarArchiveBuilder extends AbstractArchiveBuilder /** @var \PharFileInfo $fileInfo */ $fileInfo = $this->tar[$pathToDir]; +<<<<<<< HEAD <<<<<<< HEAD if ($fileInfo->isDir()) { ======= if($fileInfo->isDir()) { >>>>>>> Finish implementing and testing zip +======= + if ($fileInfo->isDir()) { +>>>>>>> Fix cs $isDir = true; } /** * Catch the exception to avoid its displaying. */ +<<<<<<< HEAD <<<<<<< HEAD } catch (\BadMethodCallException $e) {} ======= } catch(\BadMethodCallException $e) {} >>>>>>> Finish implementing and testing zip +======= + } catch (\BadMethodCallException $e) {} +>>>>>>> Fix cs return $isDir; } /** +<<<<<<< HEAD <<<<<<< HEAD * @param string $environment ======= * @param string $environment >>>>>>> Finish implementing and testing zip +======= + * @param string $environment +>>>>>>> Fix cs * @return $this * * Sets the execution environment of the Kernel, @@ -619,6 +678,7 @@ class TarArchiveBuilder extends AbstractArchiveBuilder $this->compressionEntryPoint(); } catch (\BadMethodCallException $e) { +<<<<<<< HEAD ======= switch ($this->compression) { case "gz": @@ -637,15 +697,21 @@ class TarArchiveBuilder extends AbstractArchiveBuilder } catch(\BadMethodCallException $e) { >>>>>>> Finish implementing and testing zip +======= +>>>>>>> Fix cs /** * This should not happen */ $errorMessage = "You have badly called the method setEnvironment twice for %file"; +<<<<<<< HEAD <<<<<<< HEAD } catch (\UnexpectedValueException $e) { ======= } catch(\UnexpectedValueException $e) { >>>>>>> Finish implementing and testing zip +======= + } catch (\UnexpectedValueException $e) { +>>>>>>> Fix cs $errorMessage = "The file %file is corrupted"; } @@ -674,11 +740,15 @@ class TarArchiveBuilder extends AbstractArchiveBuilder } /** +<<<<<<< HEAD <<<<<<< HEAD * @param string $initialString ======= * @param string $initialString >>>>>>> Finish implementing and testing zip +======= + * @param string $initialString +>>>>>>> Fix cs * @return string * * Gives a valid file path for \ZipArchive @@ -699,11 +769,15 @@ class TarArchiveBuilder extends AbstractArchiveBuilder } /** +<<<<<<< HEAD <<<<<<< HEAD * @param string $initialString ======= * @param string $initialString >>>>>>> Finish implementing and testing zip +======= + * @param string $initialString +>>>>>>> Fix cs * @return string * * Gives a valid directory path for \ZipArchive @@ -811,5 +885,9 @@ class TarArchiveBuilder extends AbstractArchiveBuilder { return $this->compression; } +<<<<<<< HEAD } >>>>>>> Finish tar, tar.gz, tar.bz2 and tests +======= +} +>>>>>>> Fix cs diff --git a/core/lib/Thelia/Core/FileFormat/Archive/ArchiveBuilder/TarBz2ArchiveBuilder.php b/core/lib/Thelia/Core/FileFormat/Archive/ArchiveBuilder/TarBz2ArchiveBuilder.php index 201c19234..1b198bd8c 100644 --- a/core/lib/Thelia/Core/FileFormat/Archive/ArchiveBuilder/TarBz2ArchiveBuilder.php +++ b/core/lib/Thelia/Core/FileFormat/Archive/ArchiveBuilder/TarBz2ArchiveBuilder.php @@ -45,7 +45,11 @@ class TarBz2ArchiveBuilder extends TarArchiveBuilder return $this; } <<<<<<< HEAD +<<<<<<< HEAD } ======= } >>>>>>> Finish tar, tar.gz, tar.bz2 and tests +======= +} +>>>>>>> Fix cs diff --git a/core/lib/Thelia/Core/FileFormat/Archive/ArchiveBuilder/TarGzArchiveBuilder.php b/core/lib/Thelia/Core/FileFormat/Archive/ArchiveBuilder/TarGzArchiveBuilder.php index 6ba4cd8cf..5ae97afff 100644 --- a/core/lib/Thelia/Core/FileFormat/Archive/ArchiveBuilder/TarGzArchiveBuilder.php +++ b/core/lib/Thelia/Core/FileFormat/Archive/ArchiveBuilder/TarGzArchiveBuilder.php @@ -49,8 +49,12 @@ class TarGzArchiveBuilder extends TarArchiveBuilder return $this; } +<<<<<<< HEAD <<<<<<< HEAD } ======= } >>>>>>> Finish tar, tar.gz, tar.bz2 and tests +======= +} +>>>>>>> Fix cs diff --git a/core/lib/Thelia/Core/FileFormat/Archive/ArchiveBuilder/ZipArchiveBuilder.php b/core/lib/Thelia/Core/FileFormat/Archive/ArchiveBuilder/ZipArchiveBuilder.php index 5113d2fde..9261cba3a 100644 --- a/core/lib/Thelia/Core/FileFormat/Archive/ArchiveBuilder/ZipArchiveBuilder.php +++ b/core/lib/Thelia/Core/FileFormat/Archive/ArchiveBuilder/ZipArchiveBuilder.php @@ -94,11 +94,15 @@ class ZipArchiveBuilder extends AbstractArchiveBuilder * On the destruction of the class, * remove the temporary file. */ +<<<<<<< HEAD <<<<<<< HEAD public function __destruct() ======= function __destruct() >>>>>>> Define archive builders and formatters +======= + public function __destruct() +>>>>>>> Fix cs { if ($this->zip instanceof \ZipArchive) { @$this->zip->close(); @@ -126,10 +130,14 @@ class ZipArchiveBuilder extends AbstractArchiveBuilder /** <<<<<<< HEAD +<<<<<<< HEAD +======= +>>>>>>> Fix cs * @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 +<<<<<<< HEAD * @return $this * @throws \Thelia\Exception\FileNotFoundException * @throws \Thelia\Exception\FileNotReadableException @@ -139,6 +147,8 @@ class ZipArchiveBuilder extends AbstractArchiveBuilder * @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 +======= +>>>>>>> Fix cs * @return $this * @throws \Thelia\Exception\FileNotFoundException * @throws \Thelia\Exception\FileNotReadableException @@ -163,6 +173,7 @@ class ZipArchiveBuilder extends AbstractArchiveBuilder */ if (!empty($directoryInArchive)) { +<<<<<<< HEAD $this->addDirectory($directoryInArchive); } @@ -270,6 +281,8 @@ class ZipArchiveBuilder extends AbstractArchiveBuilder */ if(!empty($directoryInArchive)) { +======= +>>>>>>> Fix cs $this->addDirectory($directoryInArchive); } @@ -443,7 +456,7 @@ class ZipArchiveBuilder extends AbstractArchiveBuilder /** * @param $content * @param $name - * @param string $directoryInArchive + * @param string $directoryInArchive * @return mixed * @throws \ErrorException * @@ -510,7 +523,7 @@ class ZipArchiveBuilder extends AbstractArchiveBuilder } /** - * @param string $pathToFile + * @param string $pathToFile * @return null|string * @throws \Thelia\Exception\FileNotFoundException * @throws \Thelia\Exception\FileNotReadableException @@ -540,7 +553,7 @@ class ZipArchiveBuilder extends AbstractArchiveBuilder /** - * @param string $initialString + * @param string $initialString * @return string * * Gives a valid file path for \ZipArchive @@ -560,11 +573,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 @@ -717,6 +731,7 @@ class ZipArchiveBuilder extends AbstractArchiveBuilder } /** +<<<<<<< HEAD <<<<<<< HEAD * @param string $pathToArchive * @param bool $isOnline @@ -730,6 +745,11 @@ class ZipArchiveBuilder extends AbstractArchiveBuilder * @return $this >>>>>>> Define archive builders and formatters ======= +======= + * @param string $pathToArchive + * @param bool $isOnline + * @param FileDownloaderInterface $fileDownloader +>>>>>>> Fix cs * @return ZipArchiveBuilder >>>>>>> Finish tar, tar.gz, tar.bz2 and tests * @throws \Thelia\Exception\FileNotFoundException @@ -828,11 +848,15 @@ class ZipArchiveBuilder extends AbstractArchiveBuilder } /** +<<<<<<< HEAD <<<<<<< HEAD * @param string $directory ======= * @param string $directory >>>>>>> Define archive builders and formatters +======= + * @param string $directory +>>>>>>> Fix cs * @return bool * * Checks if the link $directory exists and if it's not a file. @@ -853,11 +877,15 @@ class ZipArchiveBuilder extends AbstractArchiveBuilder } /** +<<<<<<< HEAD <<<<<<< HEAD * @param string $environment ======= * @param string $environment >>>>>>> Define archive builders and formatters +======= + * @param string $environment +>>>>>>> Fix cs * @return $this * * Sets the execution environment of the Kernel, @@ -927,6 +955,7 @@ class ZipArchiveBuilder extends AbstractArchiveBuilder \ZipArchive::CREATE ); +<<<<<<< HEAD <<<<<<< HEAD if ($opening !== true) { throw new \ErrorException( @@ -934,6 +963,9 @@ class ZipArchiveBuilder extends AbstractArchiveBuilder "An unknown error append" ======= if($opening !== true) { +======= + if ($opening !== true) { +>>>>>>> Fix cs throw new \ErrorException( $this->translator->trans( <<<<<<< HEAD @@ -1052,11 +1084,15 @@ class ZipArchiveBuilder extends AbstractArchiveBuilder } /** +<<<<<<< HEAD <<<<<<< HEAD * @param string $initialString ======= * @param string $initialString >>>>>>> Define archive builders and formatters +======= + * @param string $initialString +>>>>>>> Fix cs * @return string * * Gives a valid file path for \ZipArchive @@ -1085,18 +1121,26 @@ class ZipArchiveBuilder extends AbstractArchiveBuilder $initialString = "/" . $initialString; } <<<<<<< HEAD +<<<<<<< HEAD ======= >>>>>>> Define archive builders and formatters +======= + +>>>>>>> Fix cs return $initialString; } /** +<<<<<<< HEAD <<<<<<< HEAD * @param string $initialString ======= * @param string $initialString >>>>>>> Define archive builders and formatters +======= + * @param string $initialString +>>>>>>> Fix cs * @return string * * Gives a valid directory path for \ZipArchive @@ -1219,6 +1263,7 @@ class ZipArchiveBuilder extends AbstractArchiveBuilder } <<<<<<< HEAD <<<<<<< HEAD +<<<<<<< HEAD } ======= @@ -1240,3 +1285,6 @@ class ZipArchiveBuilder extends AbstractArchiveBuilder ======= } >>>>>>> Finish implementing and testing zip +======= +} +>>>>>>> Fix cs diff --git a/core/lib/Thelia/Core/FileFormat/Archive/ArchiveBuilderInterface.php b/core/lib/Thelia/Core/FileFormat/Archive/ArchiveBuilderInterface.php index 5b2273889..3eb0aaa84 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 @@ -32,10 +31,14 @@ interface ArchiveBuilderInterface { /** <<<<<<< HEAD +<<<<<<< HEAD +======= +>>>>>>> Fix cs * @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 +<<<<<<< HEAD * @return $this * @throws \Thelia\Exception\FileNotFoundException * @throws \Thelia\Exception\FileNotReadableException @@ -45,6 +48,8 @@ interface ArchiveBuilderInterface * @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 +======= +>>>>>>> Fix cs * @return $this * @throws \Thelia\Exception\FileNotFoundException * @throws \Thelia\Exception\FileNotReadableException @@ -69,8 +74,12 @@ interface ArchiveBuilderInterface ======= * @param $content * @param $name +<<<<<<< HEAD * @param string $directoryInArchive >>>>>>> Finish implementing and testing zip +======= + * @param string $directoryInArchive +>>>>>>> Fix cs * @return mixed * @throws \ErrorException * @@ -79,11 +88,15 @@ interface ArchiveBuilderInterface public function addFileFromString($content, $name, $directoryInArchive = "/"); /** +<<<<<<< HEAD <<<<<<< HEAD * @param string $pathToFile ======= * @param string $pathToFile >>>>>>> Finish implementing and testing zip +======= + * @param string $pathToFile +>>>>>>> Fix cs * @return null|string * @throws \Thelia\Exception\FileNotFoundException * @throws \Thelia\Exception\FileNotReadableException @@ -149,6 +162,7 @@ interface ArchiveBuilderInterface public function buildArchiveResponse(); /** +<<<<<<< HEAD * @param string $pathToArchive * @param bool $isOnline <<<<<<< HEAD @@ -159,6 +173,10 @@ interface ArchiveBuilderInterface >>>>>>> Finish implementing and testing zip ======= >>>>>>> Finish tar, tar.gz, tar.bz2 and tests +======= + * @param string $pathToArchive + * @param bool $isOnline +>>>>>>> Fix cs * @return $this * @throws \Thelia\Exception\FileNotFoundException * @throws \Thelia\Exception\HttpUrlException @@ -188,17 +206,22 @@ interface ArchiveBuilderInterface public function hasFile($pathToFile); /** +<<<<<<< HEAD <<<<<<< HEAD * @param string $directory ======= * @param string $directory >>>>>>> Define archive builders and formatters +======= + * @param string $directory +>>>>>>> Fix cs * @return bool * * Check if the archive has a directory */ public function hasDirectory($directory); +<<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD } @@ -216,3 +239,6 @@ interface ArchiveBuilderInterface ======= } >>>>>>> Finish tar, tar.gz, tar.bz2 and tests +======= +} +>>>>>>> Fix cs diff --git a/core/lib/Thelia/Core/FileFormat/Archive/ArchiveBuilderManager.php b/core/lib/Thelia/Core/FileFormat/Archive/ArchiveBuilderManager.php index 7e62c2c34..e8a13a20e 100644 --- a/core/lib/Thelia/Core/FileFormat/Archive/ArchiveBuilderManager.php +++ b/core/lib/Thelia/Core/FileFormat/Archive/ArchiveBuilderManager.php @@ -34,6 +34,7 @@ class ArchiveBuilderManager $this->environment = $environment; } /** +<<<<<<< HEAD <<<<<<< HEAD * @param AbstractArchiveBuilder $archiveBuilder * @return $this @@ -46,6 +47,9 @@ class ArchiveBuilderManager $this->archiveBuilders[$archiveBuilder->getName()] = $archiveBuilder; ======= * @param AbstractArchiveBuilder $archiveCreator +======= + * @param AbstractArchiveBuilder $archiveCreator +>>>>>>> Fix cs * @return $this */ public function add(AbstractArchiveBuilder $archiveCreator) @@ -143,5 +147,9 @@ class ArchiveBuilderManager { return $this->archiveCreators; } +<<<<<<< HEAD } >>>>>>> Define archive builders and formatters +======= +} +>>>>>>> Fix cs diff --git a/core/lib/Thelia/Core/FileFormat/FormatInterface.php b/core/lib/Thelia/Core/FileFormat/FormatInterface.php index f51e35905..290bdabc5 100644 --- a/core/lib/Thelia/Core/FileFormat/FormatInterface.php +++ b/core/lib/Thelia/Core/FileFormat/FormatInterface.php @@ -56,7 +56,11 @@ interface FormatInterface */ public function getMimeType(); <<<<<<< HEAD +<<<<<<< HEAD } ======= } >>>>>>> Define archive builders and formatters +======= +} +>>>>>>> Fix cs 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 36b57e8be..03490d45a 100644 --- a/core/lib/Thelia/Tests/FileFormat/Archive/ArchiveBuilder/TarArchiveBuilderTest.php +++ b/core/lib/Thelia/Tests/FileFormat/Archive/ArchiveBuilder/TarArchiveBuilderTest.php @@ -457,7 +457,7 @@ class TarArchiveBuilderTest extends \PHPUnit_Framework_TestCase $this->tar->formatDirectoryPath("//foo/bar///baz/") ); } - + public function testFormatFilePath() { $this->assertEquals( @@ -522,5 +522,9 @@ class TarArchiveBuilderTest extends \PHPUnit_Framework_TestCase $this->tar->getCompression() ); } +<<<<<<< HEAD } >>>>>>> Finish tar, tar.gz, tar.bz2 and tests +======= +} +>>>>>>> Fix cs diff --git a/core/lib/Thelia/Tests/FileFormat/Archive/ArchiveBuilder/TarBz2ArchiveBuilderTest.php b/core/lib/Thelia/Tests/FileFormat/Archive/ArchiveBuilder/TarBz2ArchiveBuilderTest.php index c4ec0dd3b..47bd9e82d 100644 --- a/core/lib/Thelia/Tests/FileFormat/Archive/ArchiveBuilder/TarBz2ArchiveBuilderTest.php +++ b/core/lib/Thelia/Tests/FileFormat/Archive/ArchiveBuilder/TarBz2ArchiveBuilderTest.php @@ -36,7 +36,11 @@ class TarBz2ArchiveBuilderTest extends TarArchiveBuilderTest ); } <<<<<<< HEAD +<<<<<<< HEAD } ======= } >>>>>>> Finish tar, tar.gz, tar.bz2 and tests +======= +} +>>>>>>> Fix cs diff --git a/core/lib/Thelia/Tests/FileFormat/Archive/ArchiveBuilder/TarGzArchiveBuilderTest.php b/core/lib/Thelia/Tests/FileFormat/Archive/ArchiveBuilder/TarGzArchiveBuilderTest.php index 6f6f526cf..324d5f2dc 100644 --- a/core/lib/Thelia/Tests/FileFormat/Archive/ArchiveBuilder/TarGzArchiveBuilderTest.php +++ b/core/lib/Thelia/Tests/FileFormat/Archive/ArchiveBuilder/TarGzArchiveBuilderTest.php @@ -13,9 +13,12 @@ namespace Thelia\Tests\FileFormat\Archive\ArchiveBuilder; use Thelia\Core\FileFormat\Archive\ArchiveBuilder\TarGzArchiveBuilder; <<<<<<< HEAD +<<<<<<< HEAD ======= use Thelia\Core\HttpFoundation\Response; >>>>>>> Finish tar, tar.gz, tar.bz2 and tests +======= +>>>>>>> Fix cs /** * Class TarGzArchiveBuilderTest @@ -40,7 +43,11 @@ class TarGzArchiveBuilderTest extends TarArchiveBuilderTest ); } <<<<<<< HEAD +<<<<<<< HEAD } ======= } >>>>>>> Finish tar, tar.gz, tar.bz2 and tests +======= +} +>>>>>>> Fix cs diff --git a/core/lib/Thelia/Tests/FileFormat/Archive/ArchiveBuilder/ZipArchiveBuilderTest.php b/core/lib/Thelia/Tests/FileFormat/Archive/ArchiveBuilder/ZipArchiveBuilderTest.php index 52feada77..fa8ea74d1 100644 --- a/core/lib/Thelia/Tests/FileFormat/Archive/ArchiveBuilder/ZipArchiveBuilderTest.php +++ b/core/lib/Thelia/Tests/FileFormat/Archive/ArchiveBuilder/ZipArchiveBuilderTest.php @@ -693,6 +693,7 @@ class ZipArchiveBuilderTest extends \PHPUnit_Framework_TestCase ); } +<<<<<<< HEAD <<<<<<< HEAD } ======= @@ -701,3 +702,6 @@ class ZipArchiveBuilderTest extends \PHPUnit_Framework_TestCase ======= } >>>>>>> Finish implementing and testing zip +======= +} +>>>>>>> Fix cs diff --git a/core/lib/Thelia/Tests/FileFormat/Archive/ArchiveBuilderManagerTest.php b/core/lib/Thelia/Tests/FileFormat/Archive/ArchiveBuilderManagerTest.php index 7e92216bf..f5907f49c 100644 --- a/core/lib/Thelia/Tests/FileFormat/Archive/ArchiveBuilderManagerTest.php +++ b/core/lib/Thelia/Tests/FileFormat/Archive/ArchiveBuilderManagerTest.php @@ -72,8 +72,12 @@ class ArchiveBuilderManagerTest extends \PHPUnit_Framework_TestCase $this->manager->delete("foo"); } +<<<<<<< HEAD <<<<<<< HEAD } ======= } >>>>>>> Define archive builders and formatters +======= +} +>>>>>>> Fix cs 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 eb3a32918..524ef3aa7 100644 --- a/core/lib/Thelia/Tests/Tools/FakeFileDownloader.php +++ b/core/lib/Thelia/Tests/Tools/FakeFileDownloader.php @@ -22,6 +22,7 @@ use Thelia\Tools\FileDownload\FileDownloader; class FakeFileDownloader extends FileDownloader { /** +<<<<<<< HEAD <<<<<<< HEAD * @param string $url * @param string $pathToStore @@ -29,6 +30,10 @@ class FakeFileDownloader extends FileDownloader * @param string $url * @param string $pathToStore >>>>>>> Define archive builders and formatters +======= + * @param string $url + * @param string $pathToStore +>>>>>>> Fix cs * @throws \Thelia\Exception\FileNotFoundException * @throws \ErrorException * @throws \HttpUrlException @@ -46,8 +51,12 @@ class FakeFileDownloader extends FileDownloader } } +<<<<<<< HEAD <<<<<<< HEAD } ======= } >>>>>>> Define archive builders and formatters +======= +} +>>>>>>> Fix cs diff --git a/core/lib/Thelia/Tests/Tools/FileDownloaderTest.php b/core/lib/Thelia/Tests/Tools/FileDownloaderTest.php index 263d67db7..2c5a0c2a8 100644 --- a/core/lib/Thelia/Tests/Tools/FileDownloaderTest.php +++ b/core/lib/Thelia/Tests/Tools/FileDownloaderTest.php @@ -69,7 +69,11 @@ class FileDownloaderTest extends \PHPUnit_Framework_TestCase $this->downloader->download("https://github.com/thelia/thelia", "php://temp"); } <<<<<<< HEAD +<<<<<<< HEAD } ======= } >>>>>>> Define archive builders and formatters +======= +} +>>>>>>> Fix cs