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

DisplayRenderer::render()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 3
c 1
b 0
f 0
nc 2
nop 1
dl 0
loc 7
ccs 4
cts 4
cp 1
crap 2
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 StylesRendererInterface
14
{
15
16
    /**
17
     * @var Display|null
18
     */
19
    private $display;
20
21 139
    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 139
        $this->display = $display;
24 139
    }
25
26 118
    public function render(string $text): string
27
    {
28 118
        if (null === $this->display) {
29 118
            return $text;
30
        }
31
32 2
        return sprintf("<div class=\"csl-%s\">%s</div>", (string)$this->display, $text);
33
    }
34
}
35