Completed
Push — master ( 6054a8...c11aa8 )
by Kacper
04:06
created

Ini::getAliases()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 5

Duplication

Lines 8
Ratio 100 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 5
c 1
b 0
f 0
nc 1
nop 0
dl 8
loc 8
rs 9.4285
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*(.*)/i')),
36
        ]);
37
    }
38
39
    /** @inheritdoc */
40
    public function getIdentifier()
41
    {
42
        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