StringWriter   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 6
c 1
b 0
f 1
dl 0
loc 38
rs 10
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A writeGame() 0 3 1
A getPgn() 0 3 1
A __construct() 0 5 1
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 StringWriter extends AbstractWriter
13
{
14
    /**
15
     * @var string
16
     */
17
    private $pgn;
18
19
    /**
20
     * Initializes a new instance of this class.
21
     *
22
     * @param bool $showMoveNumberTwice Whether or not to repeat the move number.
23
     */
24
    public function __construct(bool $showMoveNumberTwice = false)
25
    {
26
        parent::__construct($showMoveNumberTwice);
27
28
        $this->pgn = '';
29
    }
30
31
    /**
32
     * Gets the PGN data that was written.
33
     *
34
     * @return string
35
     */
36
    public function getPgn(): string
37
    {
38
        return $this->pgn;
39
    }
40
41
    /**
42
     * Writes a single game.
43
     *
44
     * @param string $pgn The PGN data of a single game.
45
     * @return void
46
     */
47
    protected function writeGame(string $pgn): void
48
    {
49
        $this->pgn .= $pgn;
50
    }
51
}
52