Favor object creation in factories (#459)
Instead of passing factories in the constructors and let objects call the factory method, create all dependencies directly in the factories.
This commit is contained in:
1 parent
4ec3a21170
commit
61f2addefa
13 files changed
+84
-114
No files matched your search
@@ -37,18 +37,19 @@ class EntityFactory implements EntityFactoryInterface
|
||||
*/
|
||||
public function createSheetIterator($filePointer, $optionsManager, $globalFunctionsHelper)
|
||||
{
|
||||
return new SheetIterator($filePointer, $optionsManager, $globalFunctionsHelper, $this);
|
||||
$rowIterator = $this->createRowIterator($filePointer, $optionsManager, $globalFunctionsHelper);
|
||||
$sheet = $this->createSheet($rowIterator);
|
||||
|
||||
return new SheetIterator($sheet);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param resource $filePointer Pointer to the CSV file to read
|
||||
* @param OptionsManagerInterface $optionsManager
|
||||
* @param GlobalFunctionsHelper $globalFunctionsHelper
|
||||
* @param RowIterator $rowIterator
|
||||
* @return Sheet
|
||||
*/
|
||||
public function createSheet($filePointer, $optionsManager, $globalFunctionsHelper)
|
||||
private function createSheet($rowIterator)
|
||||
{
|
||||
return new Sheet($filePointer, $optionsManager, $globalFunctionsHelper, $this);
|
||||
return new Sheet($rowIterator);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -57,7 +58,7 @@ class EntityFactory implements EntityFactoryInterface
|
||||
* @param GlobalFunctionsHelper $globalFunctionsHelper
|
||||
* @return RowIterator
|
||||
*/
|
||||
public function createRowIterator($filePointer, $optionsManager, $globalFunctionsHelper)
|
||||
private function createRowIterator($filePointer, $optionsManager, $globalFunctionsHelper)
|
||||
{
|
||||
$encodingHelper = $this->helperFactory->createEncodingHelper($globalFunctionsHelper);
|
||||
return new RowIterator($filePointer, $optionsManager, $encodingHelper, $globalFunctionsHelper);
|
||||
|
||||
Reference in new issue
Block a user