TypographService::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 1
1
<?php
2
3
namespace Fenrizbes\TypographBundle\Service;
4
5
use Fenrizbes\TypographBundle\EMT\EMTypograph;
6
use Symfony\Component\Config\Definition\Exception\InvalidConfigurationException;
7
8
class TypographService
9
{
10
    protected $configs;
11
12
    public function __construct($configs)
13
    {
14
        $this->configs = $configs;
15
    }
16
17
    public function apply($string, $config = null)
18
    {
19
        if (is_null($config)) {
20
            $config = 'default';
21
        }
22
23
        if (!isset($this->configs[$config])) {
24
            throw new InvalidConfigurationException('Typograph\'s config "'. $config .'" doesn\'t exist');
25
        }
26
27
        return EMTypograph::fast_apply($string, $this->configs[$config]);
28
    }
29
}