RuleTrait::consumeHr()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 2
crap 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\block;
9
10
/**
11
 * Adds horizontal rules
12
 */
13
trait RuleTrait
14
{
15
    /**
16
     * identify a line as a horizontal rule.
17
     * The exact string of '----', with possible white spaces before and/or after it
18
     */
19 23
    protected function identifyHr($line)
20
    {
21 23
        return preg_match('/^\s*----\s*$/', $line);
22
    }
23
24
    /**
25
     * Consume a horizontal rule
26
     */
27 3
    protected function consumeHr($lines, $current)
0 ignored issues
show
Unused Code introduced by
The parameter $lines is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
28
    {
29 3
        return [['hr'], $current];
30
    }
31
32
    /**
33
     * Renders a horizontal rule
34
     */
35 3
    protected function renderHr($block)
0 ignored issues
show
Unused Code introduced by
The parameter $block is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
36
    {
37 3
        return $this->html5 ? "<hr>\n" : "<hr />\n";
0 ignored issues
show
Bug introduced by
The property html5 does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
38
    }
39
40
}