Completed
Pull Request — master (#13)
by Peter
04:05
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 1
    public function __construct(LoggerInterface $logger)
28
    {
29 1
        $this->logger = $logger;
30 1
    }
31
32 1
    public function open(): void
33
    {
34
        // do nothing
35 1
    }
36
37 1
    public function close(): void
38
    {
39
        // do nothing
40 1
    }
41
42
    /**
43
     * @param Url $url
44
     */
45 1
    public function push(Url $url): void
46
    {
47 1
        $this->logger->debug(sprintf('URL "%s" was added to sitemap.xml', $url->getLoc()), [
48 1
            'changefreq' => $url->getChangeFreq(),
49 1
            'lastmod' => $url->getLastMod(),
50 1
            'priority' => $url->getPriority(),
51
        ]);
52 1
    }
53
}
54