Completed
Push — master ( 0d3592...0bb29a )
by Peter
06:28
created

LoggerStream   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 51
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

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

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A open() 0 4 1
A close() 0 4 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
    public function __construct(LoggerInterface $logger)
31
    {
32
        $this->logger = $logger;
33
    }
34
35
    public function open()
36
    {
37
        // do nothing
38
    }
39
40
    public function close()
41
    {
42
        // do nothing
43
    }
44
45
    /**
46
     * @param Url $url
47
     */
48
    public function push(Url $url)
49
    {
50
        $this->logger->debug(sprintf('URL "%s" is added to sitemap', $url->getLoc()), [
51
            'changefreq' => $url->getChangeFreq(),
52
            'lastmod' => $url->getLastMod(),
53
            'priority' => $url->getPriority(),
54
        ]);
55
        ++$this->counter;
56
    }
57
58
    /**
59
     * @return int
60
     */
61
    public function count()
62
    {
63
        return $this->counter;
64
    }
65
}
66