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

DisplayRenderer   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Test Coverage

Coverage 85.71%

Importance

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

2 Methods

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