Completed
Push — master ( efd42a...575f81 )
by Hannes
02:14
created

FormatFactory   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 1
Bugs 1 Features 0
Metric Value
wmc 5
c 1
b 1
f 0
lcom 0
cbo 1
dl 0
loc 24
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
B createFormat() 0 12 5
1
<?php
2
3
namespace hanneskod\readmetester\Format;
4
5
use RuntimeException;
6
7
/**
8
 * Create Readme file format based on identifier
9
 */
10
class FormatFactory
11
{
12
    /**
13
     * Create file format
14
     *
15
     * @see https://github.com/github/markup
16
     *
17
     * @param  string $identifier
18
     * @return FormatInterface
19
     * @throws RuntimeException If identifier is not supported
20
     */
21
    public function createFormat($identifier)
22
    {
23
        switch (strtolower($identifier)) {
24
            case 'markdown':
25
                // no break
26
            case 'mdown':
27
            case 'mkdn':
28
            case 'md':
29
                return new Markdown;
30
        }
31
        throw new RuntimeException("Unknown identifier $identifier");
32
    }
33
}
34