AsideParser   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 4

Test Coverage

Coverage 81.25%

Importance

Changes 0
Metric Value
wmc 5
lcom 0
cbo 4
dl 0
loc 28
ccs 13
cts 16
cp 0.8125
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A parse() 0 19 5
1
<?php
2
3
/*
4
 * This file is part of the league/commonmark package.
5
 *
6
 * (c) Davey Shafik <[email protected]
7
 * (c) Colin O'Dell <[email protected]>
8
 * (c) Dan Hunsaker <[email protected]>
9
 *
10
 * Original code based on the CommonMark JS reference parser (http://bitly.com/commonmarkjs)
11
 *  - (c) John MacFarlane
12
 *
13
 * For the full copyright and license information, please view the LICENSE
14
 * file that was distributed with this source code.
15
 */
16
17
namespace Danhunsaker\Markua\Block\Parser;
18
19
use League\CommonMark\Block\Parser\AbstractBlockParser;
20
use League\CommonMark\ContextInterface;
21
use League\CommonMark\Cursor;
22
use Danhunsaker\Markua\Block\Element\Aside;
23
24
class AsideParser extends AbstractBlockParser
25
{
26
    /**
27
     * @param ContextInterface $context
28
     * @param Cursor $cursor
29
     *
30
     * @return bool
31
     */
32 30
    public function parse(ContextInterface $context, Cursor $cursor)
33
    {
34 30
        if ($cursor->getNextNonSpaceCharacter() !== 'A' ||
35 30
            $cursor->getCharacter($cursor->getNextNonSpacePosition() + 1) !== '>') {
36 30
            return false;
37
        }
38
39 7
        $cursor->advanceToNextNonSpaceOrNewline();
40 7
        if ($cursor->peek() === '>') {
41 7
            $cursor->advanceBy(2);
42 7
            if ($cursor->getCharacter() === ' ') {
43 7
                $cursor->advance();
44 7
            }
45 7
        }
46
47 7
        $context->addBlock(new Aside());
48
49 7
        return true;
50
    }
51
}
52