Test Failed
Push — master ( d3e9ef...1b9271 )
by Johannes
04:34
created

SaveContentConfigObserver   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 54
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

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

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A __invoke() 0 4 1
A getConfigWriter() 0 4 1
A getTargetPath() 0 4 1
1
<?php
2
/**
3
 * Lichtenwallner  (https://lichtenwallner.at)
4
 *
5
 * @see https://github.com/jolicht/markdown-cms for the canonical source repository
6
 * @license https://github.com/jolicht/markdown-cms/blob/master/LICENSE MIT
7
 * @copyright Copyright (c) Johannes Lichtenwallner
8
 */
9
declare(strict_types = 1);
10
namespace Jolicht\MarkdownCms\Parser\Observer;
11
12
use Zend\Config\Writer\PhpArray;
13
14
class SaveContentConfigObserver implements ParsedContentObserverInterface
15
{
16
17
    /**
18
     * Config writer
19
     *
20
     * @var PhpArray
21
     */
22
    private $configWriter;
23
24
    /**
25
     * Target path
26
     *
27
     * @var string
28
     */
29
    private $targetPath;
30
31
    public function __construct(PhpArray $configWriter,string $targetPath)
32
    {
33
        $this->configWriter = $configWriter;
34
        $this->targetPath = $targetPath;
35
    }
36
37
    /**
38
     * Save Content
39
     *
40
     * {@inheritDoc}
41
     * @see \Jolicht\MarkdownCms\Parser\Observer\ParsedContentObserverInterface::__invoke()
42
     */
43
    public function __invoke(array $config)
44
    {
45
        $this->getConfigWriter()->toFile($this->getTargetPath(), $config);
46
    }
47
48
    /**
49
     * Get config writer
50
     *
51
     * @return PhpArray
52
     */
53
    public function getConfigWriter() : PhpArray
54
    {
55
        return $this->configWriter;
56
    }
57
58
    /**
59
     * Get target path
60
     *
61
     * @return string
62
     */
63
    public function getTargetPath() : string
64
    {
65
        return $this->targetPath;
66
    }
67
}