Completed
Pull Request — master (#13)
by Peter
03:12
created

MultiStream   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 7
lcom 1
cbo 1
dl 0
loc 39
ccs 15
cts 15
cp 1
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A open() 0 6 2
A close() 0 6 2
A push() 0 6 2
1
<?php
2
declare(strict_types=1);
3
4
/**
5
 * GpsLab component.
6
 *
7
 * @author    Peter Gribanov <[email protected]>
8
 * @copyright Copyright (c) 2011, 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
16
class MultiStream implements Stream
17
{
18
    /**
19
     * @var Stream[]
20
     */
21
    private $streams = [];
22
23
    /**
24
     * @param Stream ...$streams
25
     */
26 8
    public function __construct(Stream ...$streams)
27
    {
28 8
        $this->streams = $streams;
29 8
    }
30
31 2
    public function open(): void
32
    {
33 2
        foreach ($this->streams as $stream) {
34 2
            $stream->open();
35
        }
36 2
    }
37
38 4
    public function close(): void
39
    {
40 4
        foreach ($this->streams as $stream) {
41 4
            $stream->close();
42
        }
43 4
    }
44
45
    /**
46
     * @param Url $url
47
     */
48 4
    public function push(Url $url): void
49
    {
50 4
        foreach ($this->streams as $stream) {
51 4
            $stream->push($url);
52
        }
53 4
    }
54
}
55