SyntaxHighlighter::highlight()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 10
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 10
ccs 5
cts 5
cp 1
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 5
nc 2
nop 2
crap 2
1
<?php
2
3
namespace Kaloa\Renderer;
4
5
/**
6
 * This is a transitional dummy class. GeSHi had to be removed because it was
7
 * licensed as GPL, not MIT.
8
 */
9
final class SyntaxHighlighter implements SyntaxHighlighterInterface
10
{
11
    /**
12
     *
13
     * @param string $source
14
     * @param string $language
15
     * @return string
16
     */
17
    public function highlight($source, $language = '')
18
    {
19 2
        $e = function ($s) {
20 2
            return htmlspecialchars($s, ENT_QUOTES, 'UTF-8');
21 2
        };
22
23 2
        $classStr = ('' === $language) ? ' class="language-none"' : ' class="language-' . $e($language) . '"';
24
25 2
        return '<pre><code' . $classStr . '>' . $e($source) . '</code></pre>';
26
    }
27
}
28