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

OptionsManager   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 48
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 1
dl 0
loc 48
ccs 19
cts 19
cp 1
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A getSupportedOptions() 0 9 1
A setDefaultOptions() 0 12 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
}