LoggerStream   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 52
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 5
lcom 1
cbo 2
dl 0
loc 52
ccs 17
cts 17
cp 1
rs 10
c 0
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A open() 0 4 1
A close() 0 5 1
A push() 0 9 1
A count() 0 4 1
1
<?php
2
/**
3
 * GpsLab component.
4
 *
5
 * @author    Peter Gribanov <[email protected]>
6
 * @copyright Copyright (c) 2011, Peter Gribanov
7
 * @license   http://opensource.org/licenses/MIT
8
 */
9
10
namespace GpsLab\Component\Sitemap\Stream;
11
12
use GpsLab\Component\Sitemap\Url\Url;
13
use Psr\Log\LoggerInterface;
14
15
class LoggerStream implements Stream
16
{
17
    /**
18
     * @var LoggerInterface
19
     */
20
    private $logger;
21
22
    /**
23
     * @var int
24
     */
25
    private $counter = 0;
26
27
    /**
28
     * @param LoggerInterface $logger
29
     */
30 2
    public function __construct(LoggerInterface $logger)
31
    {
32 2
        $this->logger = $logger;
33 2
    }
34
35 2
    public function open()
36
    {
37
        // do nothing
38 2
    }
39
40 2
    public function close()
41
    {
42
        // do nothing
43 2
        $this->counter = 0;
44 2
    }
45
46
    /**
47
     * @param Url $url
48
     */
49 2
    public function push(Url $url)
50
    {
51 2
        $this->logger->debug(sprintf('URL "%s" was added to sitemap.xml', $url->getLoc()), [
52 2
            'changefreq' => $url->getChangeFreq(),
53 2
            'lastmod' => $url->getLastMod(),
54 2
            'priority' => $url->getPriority(),
55
        ]);
56 2
        ++$this->counter;
57 2
    }
58
59
    /**
60
     * @return int
61
     */
62 2
    public function count()
63
    {
64 2
        return $this->counter;
65
    }
66
}
67