Completed
Push — master ( 606ca4...edcce7 )
by Kacper
05:58
created

Ini::getIdentifier()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 0
dl 0
loc 4
rs 10
c 0
b 0
f 0
ccs 2
cts 2
cp 1
crap 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\CommentMatcher;
19
use Kadet\Highlighter\Matcher\RegexMatcher;
20
use Kadet\Highlighter\Parser\Rule;
21
22
class Ini extends GreedyLanguage
23
{
24
    /**
25
     * Tokenization rules
26
     */
27
    public function setupRules()
28
    {
29
        $this->rules->addMany([
30
            'comment'        => new Rule(new CommentMatcher([';'], [])),
31
            'symbol.section' => new Rule(new RegexMatcher('/(\[.*?])/i')),
32
            'variable'       => new Rule(new RegexMatcher('/([\.\w]+)\s*=/i')),
33
            'number'         => new Rule(new RegexMatcher('/(-?\d+)/i')),
34
35
            'string' => new Rule(new RegexMatcher('/=\h*(.*?)\R/i')),
36
        ]);
37
    }
38
39
    /** @inheritdoc */
40 1
    public function getIdentifier()
41
    {
42 1
        return 'ini';
43
    }
44
45 View Code Duplication
    public static function getMetadata()
46
    {
47
        return [
48
            'name'      => ['ini'],
49
            'mime'      => ['text/x-ini', 'text/inf'],
50
            'extension' => ['*.ini', '*.cfg', '*.inf']
51
        ];
52
    }
53
}
54