Passed
Push — new-api ( e6ef7d...34a0a9 )
by Sebastian
04:34
created

DisplayRenderer::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
1
<?php
2
declare(strict_types=1);
3
/*
4
 * citeproc-php
5
 *
6
 * @link        https://github.com/seboettg/citeproc-php for the source repository
7
 * @copyright   Copyright (c) 2020 Sebastian Böttger.
8
 * @license     https://opensource.org/licenses/MIT
9
 */
10
11
namespace Seboettg\CiteProc\Styles;
12
13
final class DisplayRenderer implements StyleRendererInterface
14
{
15
16
    /**
17
     * @var Display|null
18
     */
19
    private $display;
20
21 56
    public function __construct(?Display $display = null)
0 ignored issues
show
Coding Style introduced by
Incorrect spacing between argument "$display" and equals sign; expected 0 but found 1
Loading history...
Coding Style introduced by
Incorrect spacing between default value and equals sign for argument "$display"; expected 0 but found 1
Loading history...
22
    {
23 56
        $this->display = $display;
24 56
    }
25
26 21
    public function render(string $text): string
27
    {
28 21
        if (null === $this->display) {
29 21
            return $text;
30
        }
31
32
        return sprintf("<div class=\"csl-%s\">%s</div>", (string)$this->display, $text);
33
    }
34
}
35