Completed
Push — master ( 9b98d4...f3f280 )
by Maciej
06:39
created

Ini   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Test Coverage

Coverage 16.66%

Importance

Changes 0
Metric Value
eloc 12
dl 0
loc 29
ccs 2
cts 12
cp 0.1666
rs 10
c 0
b 0
f 0
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getIdentifier() 0 3 1
A getMetadata() 0 6 1
A setupRules() 0 9 1
1
<?php
2
3
/**
4
 * Highlighter
5
 *
6
 * Copyright (C) 2016, Some right reserved.
7
 *
8
 * @author Kacper "Kadet" Donat <[email protected]>
9
 *
10
 * Contact with author:
11
 * Xmpp: [email protected]
12
 * E-mail: [email protected]
13
 *
14
 * From Kadet with love.
15
 */
16
17
namespace Kadet\Highlighter\Language;
18
19
use Kadet\Highlighter\Matcher\CommentMatcher;
20
use Kadet\Highlighter\Matcher\RegexMatcher;
21
use Kadet\Highlighter\Parser\Rule;
22
23
class Ini extends GreedyLanguage
24
{
25
    /**
26
     * Tokenization rules
27
     */
28
    public function setupRules()
29
    {
30
        $this->rules->addMany([
31
            'comment'        => new Rule(new CommentMatcher([';'], [])),
32
            'symbol.section' => new Rule(new RegexMatcher('/(\[.*?])/i')),
33
            'variable'       => new Rule(new RegexMatcher('/([\.\w]+)\s*=/i')),
34
            'number'         => new Rule(new RegexMatcher('/(-?\d+)/i')),
35
36
            'string' => new Rule(new RegexMatcher('/=\h*(.*?)\R/i')),
37
        ]);
38
    }
39
40
    /** @inheritdoc */
41 1
    public function getIdentifier()
42
    {
43 1
        return 'ini';
44
    }
45
46
    public static function getMetadata()
47
    {
48
        return [
49
            'name'      => ['ini'],
50
            'mime'      => ['text/x-ini', 'text/inf'],
51
            'extension' => ['*.ini', '*.cfg', '*.inf']
52
        ];
53
    }
54
}
55