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

DisplayRenderer   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 6
c 1
b 0
f 0
dl 0
loc 20
ccs 7
cts 7
cp 1
rs 10
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A render() 0 7 2
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