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

Ini::getMetadata()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 4
nc 1
nop 0
dl 0
loc 6
ccs 0
cts 2
cp 0
crap 2
rs 10
c 0
b 0
f 0
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