Completed
Push — 2.1 ( 1e24d9...76e6a2 )
by Dmitry
66:20 queued 62:56
created

Markdown   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 80
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 6

Test Coverage

Coverage 16.66%

Importance

Changes 0
Metric Value
wmc 6
lcom 1
cbo 6
dl 0
loc 80
ccs 2
cts 12
cp 0.1666
rs 10
c 0
b 0
f 0

6 Methods

Rating   Name   Duplication   Size   Complexity  
A renderCode() 0 4 1
A renderParagraph() 0 4 1
A renderInlineCode() 0 4 1
A renderEmph() 0 4 1
A renderStrong() 0 4 1
A renderStrike() 0 4 1
1
<?php
2
/**
3
 * @link http://www.yiiframework.com/
4
 * @copyright Copyright (c) 2008 Yii Software LLC
5
 * @license http://www.yiiframework.com/license/
6
 */
7
8
namespace yii\console;
9
10
use cebe\markdown\block\FencedCodeTrait;
11
use cebe\markdown\inline\CodeTrait;
12
use cebe\markdown\inline\EmphStrongTrait;
13
use cebe\markdown\inline\StrikeoutTrait;
14
use yii\helpers\Console;
15
16
/**
17
 * A Markdown parser that enhances markdown for reading in console environments.
18
 *
19
 * Based on [cebe/markdown](https://github.com/cebe/markdown).
20
 *
21
 * @author Carsten Brandt <[email protected]>
22
 * @since 2.0
23
 */
24
class Markdown extends \cebe\markdown\Parser
25
{
26
    use FencedCodeTrait;
27
    use CodeTrait;
28
    use EmphStrongTrait;
29
    use StrikeoutTrait;
30
31
    /**
32
     * @var array these are "escapeable" characters. When using one of these prefixed with a
33
     * backslash, the character will be outputted without the backslash and is not interpreted
34
     * as markdown.
35
     */
36
    protected $escapeCharacters = [
37
        '\\', // backslash
38
        '`', // backtick
39
        '*', // asterisk
40
        '_', // underscore
41
        '~', // tilde
42
    ];
43
44
45
    /**
46
     * Renders a code block
47
     *
48
     * @param array $block
49
     * @return string
50
     */
51
    protected function renderCode($block)
52
    {
53
        return Console::ansiFormat($block['content'], [Console::NEGATIVE]) . "\n\n";
54
    }
55
56
    /**
57
     * @inheritdoc
58
     */
59 2
    protected function renderParagraph($block)
60
    {
61 2
        return rtrim($this->renderAbsy($block['content'])) . "\n\n";
62
    }
63
64
    /**
65
     * Renders an inline code span `` ` ``.
66
     * @param array $element
67
     * @return string
68
     */
69
    protected function renderInlineCode($element)
70
    {
71
        return Console::ansiFormat($element[1], [Console::UNDERLINE]);
72
    }
73
74
    /**
75
     * Renders empathized elements.
76
     * @param array $element
77
     * @return string
78
     */
79
    protected function renderEmph($element)
80
    {
81
        return Console::ansiFormat($this->renderAbsy($element[1]), [Console::ITALIC]);
82
    }
83
84
    /**
85
     * Renders strong elements.
86
     * @param array $element
87
     * @return string
88
     */
89
    protected function renderStrong($element)
90
    {
91
        return Console::ansiFormat($this->renderAbsy($element[1]), [Console::BOLD]);
92
    }
93
94
    /**
95
     * Renders the strike through feature.
96
     * @param array $element
97
     * @return string
98
     */
99
    protected function renderStrike($element)
100
    {
101
        return Console::ansiFormat($this->parseInline($this->renderAbsy($element[1])), [Console::CROSSED_OUT]);
0 ignored issues
show
Documentation introduced by
$this->parseInline($this...enderAbsy($element[1])) is of type array<integer,array<inte...string","1":"string"}>>, but the function expects a string.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
102
    }
103
}
104