|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Box\Spout\Reader\CSV\Creator; |
|
4
|
|
|
|
|
5
|
|
|
use Box\Spout\Common\Creator\HelperFactory; |
|
6
|
|
|
use Box\Spout\Common\Helper\GlobalFunctionsHelper; |
|
7
|
|
|
use Box\Spout\Common\Manager\OptionsManagerInterface; |
|
8
|
|
|
use Box\Spout\Reader\Common\Creator\EntityFactoryInterface; |
|
9
|
|
|
use Box\Spout\Reader\CSV\RowIterator; |
|
10
|
|
|
use Box\Spout\Reader\CSV\Sheet; |
|
11
|
|
|
use Box\Spout\Reader\CSV\SheetIterator; |
|
12
|
|
|
|
|
13
|
|
|
/** |
|
14
|
|
|
* Class EntityFactory |
|
15
|
|
|
* Factory to create entities |
|
16
|
|
|
* |
|
17
|
|
|
* @package Box\Spout\Reader\CSV\Creator |
|
18
|
|
|
*/ |
|
19
|
|
|
class EntityFactory implements EntityFactoryInterface |
|
20
|
|
|
{ |
|
21
|
|
|
/** @var HelperFactory */ |
|
22
|
|
|
private $helperFactory; |
|
23
|
|
|
|
|
24
|
|
|
/** |
|
25
|
|
|
* @param HelperFactory $helperFactory |
|
26
|
|
|
*/ |
|
27
|
31 |
|
public function __construct(HelperFactory $helperFactory) |
|
28
|
|
|
{ |
|
29
|
31 |
|
$this->helperFactory = $helperFactory; |
|
30
|
31 |
|
} |
|
31
|
|
|
|
|
32
|
|
|
/** |
|
33
|
|
|
* @param resource $filePointer Pointer to the CSV file to read |
|
34
|
|
|
* @param OptionsManagerInterface $optionsManager |
|
35
|
|
|
* @param GlobalFunctionsHelper $globalFunctionsHelper |
|
36
|
|
|
* @return SheetIterator |
|
37
|
|
|
*/ |
|
38
|
26 |
|
public function createSheetIterator($filePointer, $optionsManager, $globalFunctionsHelper) |
|
39
|
|
|
{ |
|
40
|
26 |
|
return new SheetIterator($filePointer, $optionsManager, $globalFunctionsHelper, $this); |
|
41
|
|
|
} |
|
42
|
|
|
|
|
43
|
|
|
/** |
|
44
|
|
|
* @param resource $filePointer Pointer to the CSV file to read |
|
45
|
|
|
* @param OptionsManagerInterface $optionsManager |
|
46
|
|
|
* @param GlobalFunctionsHelper $globalFunctionsHelper |
|
47
|
|
|
* @return Sheet |
|
48
|
|
|
*/ |
|
49
|
26 |
|
public function createSheet($filePointer, $optionsManager, $globalFunctionsHelper) |
|
50
|
|
|
{ |
|
51
|
26 |
|
return new Sheet($filePointer, $optionsManager, $globalFunctionsHelper, $this); |
|
52
|
|
|
} |
|
53
|
|
|
|
|
54
|
|
|
/** |
|
55
|
|
|
* @param resource $filePointer Pointer to the CSV file to read |
|
56
|
|
|
* @param OptionsManagerInterface $optionsManager |
|
57
|
|
|
* @param GlobalFunctionsHelper $globalFunctionsHelper |
|
58
|
|
|
* @return RowIterator |
|
59
|
|
|
*/ |
|
60
|
26 |
|
public function createRowIterator($filePointer, $optionsManager, $globalFunctionsHelper) |
|
61
|
|
|
{ |
|
62
|
26 |
|
$encodingHelper = $this->helperFactory->createEncodingHelper($globalFunctionsHelper); |
|
63
|
26 |
|
return new RowIterator($filePointer, $optionsManager, $encodingHelper, $globalFunctionsHelper); |
|
64
|
|
|
} |
|
65
|
|
|
} |
|
66
|
|
|
|