Completed
Pull Request — develop_3.0 (#423)
by Adrien
02:30
created

OptionsManager::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 5
ccs 4
cts 4
cp 1
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 1
crap 1
1
<?php
2
3
namespace Box\Spout\Writer\XLSX\Manager;
4
5
use Box\Spout\Writer\Common\Options;
6
use Box\Spout\Writer\Style\StyleBuilder;
7
8
/**
9
 * Class OptionsManager
10
 * XLSX Writer options manager
11
 *
12
 * @package Box\Spout\Writer\XLSX\Manager
13
 */
14
class OptionsManager extends \Box\Spout\Writer\Common\Manager\OptionsManager
15
{
16
    /** Default style font values */
17
    const DEFAULT_FONT_SIZE = 12;
18
    const DEFAULT_FONT_NAME = 'Calibri';
19
20
    /** @var StyleBuilder Style builder */
21
    protected $styleBuilder;
22
23
    /**
24
     * OptionsManager constructor.
25
     * @param StyleBuilder $styleBuilder
26
     */
27 51
    public function __construct(StyleBuilder $styleBuilder)
28
    {
29 51
        $this->styleBuilder = $styleBuilder;
30 51
        parent::__construct();
31 51
    }
32
33
    /**
34
     * @inheritdoc
35
     */
36 51
    protected function getSupportedOptions()
37
    {
38
        return [
39 51
            Options::TEMP_FOLDER,
40 51
            Options::DEFAULT_ROW_STYLE,
41 51
            Options::SHOULD_CREATE_NEW_SHEETS_AUTOMATICALLY,
42 51
            Options::SHOULD_USE_INLINE_STRINGS,
43
        ];
44
    }
45
46
    /**
47
     * @inheritdoc
48
     */
49 51
    protected function setDefaultOptions()
50
    {
51 51
        $defaultRowStyle = $this->styleBuilder
52 51
            ->setFontSize(self::DEFAULT_FONT_SIZE)
53 51
            ->setFontName(self::DEFAULT_FONT_NAME)
54 51
            ->build();
55
56 51
        $this->setOption(Options::TEMP_FOLDER, sys_get_temp_dir());
57 51
        $this->setOption(Options::DEFAULT_ROW_STYLE, $defaultRowStyle);
58 51
        $this->setOption(Options::SHOULD_CREATE_NEW_SHEETS_AUTOMATICALLY, true);
59 51
        $this->setOption(Options::SHOULD_USE_INLINE_STRINGS, true);
60
    }
61
}