Completed
Pull Request — master (#649)
by Adrien
03:03 queued 33s
created

OptionsManager   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 48
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 100%

Importance

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