Test Setup Failed
Pull Request — develop_3.0 (#434)
by Hura
04:56
created

EntityFactory::createRow()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 5
ccs 0
cts 0
cp 0
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 2
crap 2
1
<?php
2
3
namespace Box\Spout\Writer\Common\Creator;
4
5
use Box\Spout\Writer\Common\Entity\Row;
6
use Box\Spout\Writer\Common\Entity\Cell;
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\SheetManager;
12
13
/**
14
 * Class EntityFactory
15
 * Factory to create entities
16
 */
17
class EntityFactory
18
{
19
    /**
20 89
     * @return Workbook
21
     */
22 89
    public function createWorkbook()
23
    {
24
        return new Workbook();
25
    }
26
27
    /**
28
     * @param string $worksheetFilePath
29
     * @param Sheet $externalSheet
30 89
     * @return Worksheet
31
     */
32 89
    public function createWorksheet($worksheetFilePath, Sheet $externalSheet)
33
    {
34
        return new Worksheet($worksheetFilePath, $externalSheet);
35
    }
36
37
    /**
38
     * @param int $sheetIndex Index of the sheet, based on order in the workbook (zero-based)
39
     * @param string $associatedWorkbookId ID of the sheet's associated workbook
40
     * @param SheetManager $sheetManager To manage sheets
41 89
     * @return Sheet
42
     */
43 89
    public function createSheet($sheetIndex, $associatedWorkbookId, $sheetManager)
44
    {
45
        return new Sheet($sheetIndex, $associatedWorkbookId, $sheetManager);
46
    }
47
48
    /**
49
     * @param mixed $cellValue
50 60
     * @return Cell
51
     */
52 60
    public function createCell($cellValue)
53
    {
54
        return new Cell($cellValue);
55
    }
56
57
    /**
58 70
     * @return \ZipArchive
59
     */
60 70
    public function createZipArchive()
61
    {
62
        return new \ZipArchive();
63
    }
64
65
    /**
66
     * @param array $cells
67
     * @param Style|null $style
68
     * @return Row
69
     */
70
    public function createRow(array $cells, Style $style = null)
71
    {
72
        $rowManager = $this->managerFactory->createRowManager();
0 ignored issues
show
Bug introduced by
The property managerFactory does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
73
        return new Row($cells, $style, $rowManager);
74
    }
75
}
76