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

FormatFactory::createFormat()   B

Complexity

Conditions 5
Paths 5

Size

Total Lines 12
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 1 Features 0
Metric Value
c 1
b 1
f 0
dl 0
loc 12
rs 8.8571
cc 5
eloc 8
nc 5
nop 1
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