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

EntityFactory   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 44
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 4
dl 0
loc 44
ccs 10
cts 10
cp 1
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A createWorkbook() 0 4 1
A createWorksheet() 0 4 1
A createSheet() 0 5 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
}