Completed
Pull Request — develop_3.0 (#433)
by Adrien
06:44
created

StyleRegistry   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 2
dl 0
loc 28
ccs 6
cts 6
cp 1
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A registerStyle() 0 7 1
A getUsedFonts() 0 4 1
1
<?php
2
3
namespace Box\Spout\Writer\ODS\Manager\Style;
4
5
use Box\Spout\Writer\Common\Entity\Style\Style;
6
7
/**
8
 * Class StyleRegistry
9
 * Registry for all used styles
10
 *
11
 * @package Box\Spout\Writer\ODS\Manager\Style
12
 */
13
class StyleRegistry extends \Box\Spout\Writer\Common\Manager\Style\StyleRegistry
14
{
15
    /** @var array [FONT_NAME] => [] Map whose keys contain all the fonts used */
16
    protected $usedFontsSet = [];
17
18
    /**
19
     * Registers the given style as a used style.
20
     * Duplicate styles won't be registered more than once.
21
     *
22
     * @param Style $style The style to be registered
23
     * @return Style The registered style, updated with an internal ID.
24
     */
25 44
    public function registerStyle(Style $style)
26
    {
27 44
        $registeredStyle = parent::registerStyle($style);
28 44
        $this->usedFontsSet[$style->getFontName()] = true;
29
30 44
        return $registeredStyle;
31
    }
32
33
    /**
34
     * @return string[] List of used fonts name
35
     */
36 35
    public function getUsedFonts()
37
    {
38 35
        return array_keys($this->usedFontsSet);
39
    }
40
}
41