Completed
Pull Request — develop_3.0 (#433)
by Adrien
08:15
created

StyleRegistry   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 26
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 26
ccs 5
cts 5
cp 1
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A registerStyle() 0 5 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 string[] [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
        $this->usedFontsSet[$style->getFontName()] = true;
28 44
        return parent::registerStyle($style);
29
    }
30
31
    /**
32
     * @return string[] List of used fonts name
33
     */
34 35
    public function getUsedFonts()
35
    {
36 35
        return array_keys($this->usedFontsSet);
37
    }
38
}
39