Factory   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A create() 0 8 2
1
<?php namespace Nord\Lumen\Search\Formatter;
2
3
use Nord\Lumen\Search\Exceptions\InvalidArgument;
4
use Nord\Lumen\Search\Contracts\Formatter;
5
6
class Factory
7
{
8
    const FORMAT_DATE = 'date';
9
    const FORMAT_LOWERCASE = 'lowercase';
10
11
    /**
12
     * @var array
13
     */
14
    private static $map = [
15
        self::FORMAT_DATE       => 'Nord\Lumen\Search\Formatter\DateFormatter',
16
        self::FORMAT_LOWERCASE  => 'Nord\Lumen\Search\Formatter\LowercaseFormatter',
17
    ];
18
19
20
    /**
21
     * @param string $format
22
     *
23
     * @return Formatter
24
     *
25
     * @throws InvalidArgument
26
     */
27
    public function create($format)
28
    {
29
        if (!isset(self::$map[$format])) {
30
            throw new InvalidArgument("Formatter '$format' is not supported.");
31
        }
32
33
        return new self::$map[$format];
34
    }
35
}
36