WriterFactory   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A create() 0 10 1
A getWriter() 0 10 2
A phpVersionLessThen5Dot4() 0 4 1
1
<?php
2
/**
3
 * @author stev leibelt <[email protected]>
4
 * @since 2015-05-06 
5
 */
6
7
namespace Net\Bazzline\Component\Csv\Writer;
8
9
use Net\Bazzline\Component\Csv\AbstractFactory;
10
11
class WriterFactory extends AbstractFactory
12
{
13
    /**
14
     * @return Writer|WriterForPhp5Dot3|WriterInterface
15
     */
16
    public function create()
17
    {
18
        $writer = $this->getWriter();
19
20
        $writer->setDelimiter($this->getDelimiter());
21
        $writer->setEnclosure($this->getEnclosure());
22
        $writer->setEscapeCharacter($this->getEscapeCharacter());
23
24
        return $writer;
25
    }
26
27
    /**
28
     * @return Writer|WriterForPhp5Dot3|WriterInterface
29
     */
30
    protected function getWriter()
31
    {
32
        if ($this->phpVersionLessThen5Dot4()) {
33
            $writer = new WriterForPhp5Dot3();
34
        } else {
35
            $writer = new Writer();
36
        }
37
38
        return $writer;
39
    }
40
41
    /**
42
     * @return boolean
43
     */
44
    protected function phpVersionLessThen5Dot4()
45
    {
46
        return (version_compare(phpversion(), '5.4', '<'));
47
    }
48
}