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

StyleRegistry::getUsedFonts()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
crap 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