Completed
Pull Request — master (#13)
by Peter
06:35
created

LoggerStream::count()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 1
1
<?php
2
declare(strict_types=1);
3
4
/**
5
 * GpsLab component.
6
 *
7
 * @author    Peter Gribanov <[email protected]>
8
 * @copyright Copyright (c) 2011-2019, Peter Gribanov
9
 * @license   http://opensource.org/licenses/MIT
10
 */
11
12
namespace GpsLab\Component\Sitemap\Stream;
13
14
use GpsLab\Component\Sitemap\Url\Url;
15
use Psr\Log\LoggerInterface;
16
17
class LoggerStream implements Stream
18
{
19
    /**
20
     * @var LoggerInterface
21
     */
22
    private $logger;
23
24
    /**
25
     * @param LoggerInterface $logger
26
     */
27
    public function __construct(LoggerInterface $logger)
28
    {
29
        $this->logger = $logger;
30 2
    }
31
32 2
    public function open(): void
33 2
    {
34
        // do nothing
35 2
    }
36
37
    public function close(): void
38 2
    {
39
        // do nothing
40 2
    }
41
42
    /**
43 2
     * @param Url $url
44 2
     */
45
    public function push(Url $url): void
46
    {
47
        $this->logger->debug(sprintf('URL "%s" was added to sitemap.xml', $url->getLoc()), [
48
            'changefreq' => $url->getChangeFreq(),
49 2
            'lastmod' => $url->getLastMod(),
50
            'priority' => $url->getPriority(),
51 2
        ]);
52 2
    }
53
}
54