CodeTrait   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 87.5%

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 0
dl 0
loc 25
ccs 7
cts 8
cp 0.875
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A parseInlineCode() 0 13 2
A renderInlineCode() 0 4 1
1
<?php
2
/**
3
 * @copyright Copyright (c) 2015 Nobuo Kihara
4
 * @license https://github.com/softark/creole/blob/master/LICENSE
5
 * @link https://github.com/softark/creole#readme
6
 */
7
8
namespace softark\creole\inline;
9
10
/**
11
 * Adds inline code elements
12
 */
13
trait CodeTrait
14
{
15
    /**
16
     * Parses an inline code span: {{{ ... }}}
17
     * @marker {{{
18
     */
19 4
    protected function parseInlineCode($text)
20
    {
21 4
        if (preg_match('/^{{{(.*?}*)}}}/s', $text, $matches)) {
22
            return [
23
                [
24 4
                    'inlineCode',
25 4
                    $matches[1],
26
                ],
27 4
                strlen($matches[0])
28
            ];
29
        }
30
        return [['text', $text[0]], 1];
31
    }
32
33 4
    protected function renderInlineCode($block)
34
    {
35 4
        return '<code>' . htmlspecialchars($block[1], ENT_NOQUOTES | ENT_SUBSTITUTE, 'UTF-8') . '</code>';
36
    }
37
}
38