Stream::writeGame()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php declare(strict_types=1);
2
/**
3
 * portable-game-notation (https://github.com/chesszebra/portable-game-notation)
4
 *
5
 * @link https://github.com/chesszebra/portable-game-notation for the canonical source repository
6
 * @copyright Copyright (c) 2017 Chess Zebra (https://chesszebra.com)
7
 * @license https://github.com/chesszebra/portable-game-notation/blob/master/LICENSE.md MIT
8
 */
9
10
namespace ChessZebra\PortableGameNotation\Writer;
11
12
final class Stream extends AbstractWriter
13
{
14
    /**
15
     * @var resource
16
     */
17
    private $resource;
18
19
    /**
20
     * Initializes a new instance of this class.
21
     *
22
     * @param resource $resource The resource to write to.
23
     * @param bool $showMoveNumberTwice Whether or not to repeat the move number.
24
     */
25
    public function __construct($resource, bool $showMoveNumberTwice = false)
26
    {
27
        $this->resource = $resource;
28
29
        parent::__construct($showMoveNumberTwice);
30
    }
31
32
    /**
33
     * Writes a single game.
34
     *
35
     * @param string $pgn The PGN data of a single game.
36
     * @return void
37
     */
38
    protected function writeGame(string $pgn): void
39
    {
40
        fwrite($this->resource, $pgn);
41
    }
42
}
43