Passed
Push — master ( ad0973...f9c297 )
by Kacper
02:48
created

Html   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 7

Importance

Changes 4
Bugs 1 Features 0
Metric Value
wmc 2
c 4
b 1
f 0
lcom 1
cbo 7
dl 0
loc 33
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A setupRules() 0 20 1
A getIdentifier() 0 4 1
1
<?php
2
/**
3
 * Highlighter
4
 *
5
 * Copyright (C) 2016, Some right reserved.
6
 *
7
 * @author Kacper "Kadet" Donat <[email protected]>
8
 *
9
 * Contact with author:
10
 * Xmpp: [email protected]
11
 * E-mail: [email protected]
12
 *
13
 * From Kadet with love.
14
 */
15
16
namespace Kadet\Highlighter\Language;
17
18
use Kadet\Highlighter\Matcher\RegexMatcher;
19
use Kadet\Highlighter\Parser\CloseRule;
20
use Kadet\Highlighter\Parser\Token\LanguageToken;
21
use Kadet\Highlighter\Parser\OpenRule;
22
use Kadet\Highlighter\Parser\TokenFactory;
23
24
class Html extends Xml
25
{
26
    /**
27
     * Tokenization rules
28
     *
29
     * @return \Kadet\Highlighter\Parser\Rule[]|\Kadet\Highlighter\Parser\Rule[][]
30
     */
31
    public function setupRules()
32
    {
33
        parent::setupRules();
34
35
        $js = new JavaScript();
36
        $this->rules->addMany([
37
            'language.'.$js->getIdentifier() => [
38
                new OpenRule(new RegexMatcher('/<script.*?>()/'), [
39
                    'factory'     => new TokenFactory(LanguageToken::class),
40
                    'inject'      => $js,
41
                    'language'    => $this,
42
                    'postProcess' => true
43
                ]),
44
                new CloseRule(new RegexMatcher('/()<\/script>/'), [
45
                    'factory'  => new TokenFactory(LanguageToken::class),
46
                    'language' => $js
47
                ])
48
            ]
49
        ]);
50
    }
51
52
    public function getIdentifier()
53
    {
54
        return 'html';
55
    }
56
}
57