Random DI improvements (#458)

* Add random DI improvements

Fixing things that were previously missed

* Split InternalFactory into Manager and Helper factories
This commit is contained in:
Adrien Loison authored and GitHub committed 2017-08-27 01:44:20 +02:00
1 parent b7e46740ce
commit 4ec3a21170
19 files changed
+317 -183

No files matched your search

+9 -3
View File
@@ -2,10 +2,10 @@
namespace Box\Spout\Writer;
use Box\Spout\Common\Creator\HelperFactory;
use Box\Spout\Common\Exception\InvalidArgumentException;
use Box\Spout\Common\Exception\IOException;
use Box\Spout\Common\Exception\SpoutException;
use Box\Spout\Common\Helper\FileSystemHelper;
use Box\Spout\Common\Helper\GlobalFunctionsHelper;
use Box\Spout\Writer\Common\Entity\Options;
use Box\Spout\Writer\Common\Entity\Style\Style;
@@ -34,6 +34,9 @@ abstract class WriterAbstract implements WriterInterface
/** @var GlobalFunctionsHelper Helper to work with global functions */
protected $globalFunctionsHelper;
/** @var HelperFactory $helperFactory */
protected $helperFactory;
/** @var OptionsManagerInterface Writer options manager */
protected $optionsManager;
@@ -50,15 +53,18 @@ abstract class WriterAbstract implements WriterInterface
* @param OptionsManagerInterface $optionsManager
* @param StyleMerger $styleMerger
* @param GlobalFunctionsHelper $globalFunctionsHelper
* @param HelperFactory $helperFactory
*/
public function __construct(
OptionsManagerInterface $optionsManager,
StyleMerger $styleMerger,
GlobalFunctionsHelper $globalFunctionsHelper)
GlobalFunctionsHelper $globalFunctionsHelper,
HelperFactory $helperFactory)
{
$this->optionsManager = $optionsManager;
$this->styleMerger = $styleMerger;
$this->globalFunctionsHelper = $globalFunctionsHelper;
$this->helperFactory = $helperFactory;
$this->resetRowStyleToDefault();
}
@@ -372,7 +378,7 @@ abstract class WriterAbstract implements WriterInterface
// remove output file if it was created
if ($this->globalFunctionsHelper->file_exists($this->outputFilePath)) {
$outputFolderPath = dirname($this->outputFilePath);
$fileSystemHelper = new FileSystemHelper($outputFolderPath);
$fileSystemHelper = $this->helperFactory->createFileSystemHelper($outputFolderPath);
$fileSystemHelper->deleteFile($this->outputFilePath);
}
}