Dumper   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 46
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 5

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A dump() 0 13 3
1
<?php
2
3
namespace Hshn\AngularBundle\TemplateCache;
4
use Symfony\Component\Filesystem\Filesystem;
5
6
/**
7
 * @author Shota Hoshino <[email protected]>
8
 */
9
class Dumper
10
{
11
    /**
12
     * @var TemplateCacheManager
13
     */
14
    private $manager;
15
16
    /**
17
     * @var TemplateFinder
18
     */
19
    private $finder;
20
21
    /**
22
     * @var Compiler
23
     */
24
    private $compiler;
25
26
    /**
27
     * @param TemplateCacheManager $manager
28
     * @param TemplateFinder       $finder
29
     * @param Compiler             $compiler
30
     */
31
    public function __construct(TemplateCacheManager $manager, TemplateFinder $finder, Compiler $compiler)
32
    {
33
        $this->manager = $manager;
34
        $this->finder = $finder;
35
        $this->compiler = $compiler;
36
    }
37
38
    /**
39
     * @param string $target
40
     */
41
    public function dump($target)
42
    {
43
        $content = '';
44
45
        foreach ($this->manager->getModules() as $name => $config) {
46
            if ($templates = $this->finder->find($config)) {
47
                $content .= $this->compiler->compile($templates, $config->getName(), $config->getCreate());
48
            }
49
        }
50
51
        $fs = new Filesystem();
52
        $fs->dumpFile($target, $content);
53
    }
54
}
55