Completed
Push — master ( 4ea848...577058 )
by Hannes
02:16
created

Factory   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

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

1 Method

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