CompressFileStream   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 64
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 6
lcom 1
cbo 2
dl 0
loc 64
ccs 19
cts 19
cp 1
rs 10
c 0
b 0
f 0

6 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A getFilename() 0 4 1
A open() 0 4 1
A close() 0 5 1
A push() 0 4 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\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 5
    public function __construct(FileStream $stream, CompressorInterface $compressor, $filename)
38
    {
39 5
        $this->substream = $stream;
40 5
        $this->compressor = $compressor;
41 5
        $this->filename = $filename;
42 5
    }
43
44
    /**
45
     * @return string
46
     */
47 1
    public function getFilename()
48
    {
49 1
        return $this->filename;
50
    }
51
52 1
    public function open()
53
    {
54 1
        $this->substream->open();
55 1
    }
56
57 1
    public function close()
58
    {
59 1
        $this->substream->close();
60 1
        $this->compressor->compress($this->substream->getFilename(), $this->filename);
61 1
    }
62
63
    /**
64
     * @param Url $url
65
     */
66 1
    public function push(Url $url)
67
    {
68 1
        $this->substream->push($url);
69 1
    }
70
71
    /**
72
     * @return int
73
     */
74 1
    public function count()
75
    {
76 1
        return $this->substream->count();
77
    }
78
}
79