Failed Conditions
Pull Request — develop_3.0 (#434)
by Hura
04:53 queued 02:03
created

EntityFactory::createRow()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 7
ccs 4
cts 4
cp 1
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 4
nc 1
nop 2
crap 1
1
<?php
2
3
namespace Box\Spout\Writer\Common\Creator;
4
5
use Box\Spout\Writer\Common\Entity\Cell;
6
use Box\Spout\Writer\Common\Entity\Row;
7
use Box\Spout\Writer\Common\Entity\Sheet;
8
use Box\Spout\Writer\Common\Entity\Style\Style;
9
use Box\Spout\Writer\Common\Entity\Workbook;
10
use Box\Spout\Writer\Common\Entity\Worksheet;
11
use Box\Spout\Writer\Common\Manager\RowManager;
12
use Box\Spout\Writer\Common\Manager\SheetManager;
13
use Box\Spout\Writer\Common\Manager\Style\StyleMerger;
14
15
/**
16
 * Class EntityFactory
17
 * Factory to create entities
18
 */
19
class EntityFactory
20
{
21
    /**
22
     * @return Workbook
23
     */
24 84
    public function createWorkbook()
25
    {
26 84
        return new Workbook();
27
    }
28
29
    /**
30
     * @param string $worksheetFilePath
31
     * @param Sheet $externalSheet
32
     * @return Worksheet
33
     */
34 84
    public function createWorksheet($worksheetFilePath, Sheet $externalSheet)
35
    {
36 84
        return new Worksheet($worksheetFilePath, $externalSheet);
37
    }
38
39
    /**
40
     * @param int $sheetIndex Index of the sheet, based on order in the workbook (zero-based)
41
     * @param string $associatedWorkbookId ID of the sheet's associated workbook
42
     * @param SheetManager $sheetManager To manage sheets
43
     * @return Sheet
44
     */
45 84
    public function createSheet($sheetIndex, $associatedWorkbookId, $sheetManager)
46
    {
47 84
        return new Sheet($sheetIndex, $associatedWorkbookId, $sheetManager);
48
    }
49
50
    /**
51
     * @param mixed $cellValue
52
     * @return Cell
53
     */
54
    public static function createCell($cellValue)
55
    {
56
        return new Cell($cellValue);
57
    }
58
59
    /**
60
     * @return \ZipArchive
61
     */
62 69
    public function createZipArchive()
63
    {
64 69
        return new \ZipArchive();
65
    }
66
67
    /**
68
     * @param array $cells
69
     * @param Style|null $style
70
     * @return Row
71
     */
72 80
    public static function createRow(array $cells, Style $style = null)
73
    {
74 80
        $styleMerger = new StyleMerger();
75 80
        $rowManager = new RowManager($styleMerger);
76
77 80
        return new Row($cells, $style, $rowManager);
78
    }
79
}
80