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

CompressFileStream::count()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 4
rs 10
c 1
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
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\Compressor\CompressorInterface;
13
use GpsLab\Component\Sitemap\Url\Url;
14
15
class CompressFileStream implements FileStream
16
{
17
    /**
18
     * @var FileStream
19
     */
20
    private $substream;
21
22
    /**
23
     * @var CompressorInterface
24
     */
25
    private $compressor;
26
27
    /**
28
     * @var string
29
     */
30
    private $filename = '';
31
32
    /**
33
     * @param FileStream          $stream
34
     * @param CompressorInterface $compressor
35
     * @param string              $filename
36
     */
37
    public function __construct(FileStream $stream, CompressorInterface $compressor, $filename)
38
    {
39
        $this->substream = $stream;
40
        $this->compressor = $compressor;
41
        $this->filename = $filename;
42
    }
43
44
    /**
45
     * @return string
46
     */
47
    public function getFilename()
48
    {
49
        return $this->filename;
50
    }
51
52
    public function open()
53
    {
54
        $this->substream->open();
55
    }
56
57
    public function close()
58
    {
59
        $this->substream->close();
60
        $this->compressor->compress($this->substream->getFilename(), $this->filename);
61
    }
62
63
    /**
64
     * @param Url $url
65
     */
66
    public function push(Url $url)
67
    {
68
        $this->substream->push($url);
69
    }
70
71
    /**
72
     * @return int
73
     */
74
    public function count()
75
    {
76
        return $this->substream->count();
77
    }
78
}
79