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

DisplayRenderer::render()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 2.0625

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 3
cts 4
cp 0.75
crap 2.0625
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