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

Ini::setupRules()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 11
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 11
rs 9.4285
cc 1
eloc 7
nc 1
nop 0
1
<?php
2
/**
3
 * Highlighter
4
 *
5
 * Copyright (C) 2015, 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\CommentMatcher;
19
use Kadet\Highlighter\Matcher\RegexMatcher;
20
use Kadet\Highlighter\Parser\Rule;
21
22
class Ini extends Language
23
{
24
    /**
25
     * Tokenization rules
26
     *
27
     * @return \Kadet\Highlighter\Parser\Rule[]|\Kadet\Highlighter\Parser\Rule[][]
28
     */
29
    public function setupRules()
30
    {
31
        $this->rules->addMany([
32
            'comment'        => new Rule(new CommentMatcher([';'], [])),
33
            'symbol.section' => new Rule(new RegexMatcher('/(\[[\.\w]+\])/i')),
34
            'variable'       => new Rule(new RegexMatcher('/([\.\w]+)\s*=/i')),
35
            'number'         => new Rule(new RegexMatcher('/(-?\d+)/i')),
36
37
            'string' => new Rule(new RegexMatcher('/=\h*(.*)/i')),
38
        ]);
39
    }
40
41
    /** @inheritdoc */
42
    public function getIdentifier()
43
    {
44
        return 'ini';
45
    }
46
}
47