Completed
Pull Request — develop_3.0 (#438)
by Adrien
02:55
created

EntityFactory::createWorkbook()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
crap 1
1
<?php
2
3
namespace Box\Spout\Writer\Common\Creator;
4
5
use Box\Spout\Writer\Common\Entity\Sheet;
6
use Box\Spout\Writer\Common\Entity\Workbook;
7
use Box\Spout\Writer\Common\Entity\Worksheet;
8
9
/**
10
 * Class EntityFactory
11
 * Factory to create entities
12
 *
13
 * @package Box\Spout\Writer\Common\Creator
14
 */
15
class EntityFactory
16
{
17
    /** @var ManagerFactory */
18
    private $managerFactory;
19
20
    /**
21
     * EntityFactory constructor.
22
     *
23
     * @param ManagerFactory $managerFactory
24
     */
25 99
    public function __construct(ManagerFactory $managerFactory)
26
    {
27 99
        $this->managerFactory = $managerFactory;
28 99
    }
29
30
    /**
31
     * @return Workbook
32
     */
33 89
    public function createWorkbook()
34
    {
35 89
        return new Workbook();
36
    }
37
38
    /**
39
     * @param string $worksheetFilePath
40
     * @param Sheet $externalSheet
41
     * @return Worksheet
42
     */
43 89
    public function createWorksheet($worksheetFilePath, Sheet $externalSheet)
44
    {
45 89
        return new Worksheet($worksheetFilePath, $externalSheet);
46
    }
47
48
    /**
49
     * @param int $sheetIndex Index of the sheet, based on order in the workbook (zero-based)
50
     * @param string $associatedWorkbookId ID of the sheet's associated workbook
51
     * @return Sheet
52
     */
53 89
    public function createSheet($sheetIndex, $associatedWorkbookId)
54
    {
55 89
        $sheetManager = $this->managerFactory->createSheetManager();
56 89
        return new Sheet($sheetIndex, $associatedWorkbookId, $sheetManager);
57
    }
58
}