Fillet   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 50
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 3
Bugs 0 Features 0
Metric Value
wmc 4
c 3
b 0
f 0
lcom 1
cbo 3
dl 0
loc 50
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A parse() 0 10 3
1
<?php
2
3
namespace Fillet;
4
5
use Fillet\Parser\ParserInterface;
6
use Fillet\Writer\WriterFactory;
7
8
/**
9
 * Mainline driver for Fillet
10
 * This class handles all the heavy lifting for turning a data source into a series of Sculpin outputs.
11
 *
12
 * @package Fillet
13
 */
14
class Fillet
15
{
16
    /**
17
     * Configuration for Fillet
18
     * @var array
19
     */
20
    protected $config;
21
22
    /**
23
     * Full path to the file we need to work against
24
     * @var string
25
     */
26
    protected $inputFile;
27
28
    /**
29
     * Parser that we will be using
30
     * @var ParserInterface
31
     */
32
    protected $parser;
33
34
    /**
35
     * Create an instance of Fillet
36
     *
37
     * @param ParserInterface $parser Parser to use
38
     * @param string $inputFile File to parse
39
     * @param array $config Fillet configuration
40
     */
41
    public function __construct(ParserInterface $parser, $inputFile, $config)
42
    {
43
        $this->parser = $parser;
44
        $this->inputFile = $inputFile;
45
        $this->config = $config;
46
    }
47
48
    /**
49
     * Calls the parser and generates the files
50
     *
51
     * @throws \Exception
52
     */
53
    public function parse()
54
    {
55
        foreach($this->parser->parse($this->inputFile) as $item) {
56
            $writer = WriterFactory::create($item['type'], $this->config);
57
58
            if($writer) {
59
                $writer->write($item);
60
            }
61
        }
62
    }
63
}