TypographService   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 2
dl 0
loc 22
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A apply() 0 12 3
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
}