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

Less   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 29
Duplicated Lines 27.59 %

Coupling/Cohesion

Components 1
Dependencies 4

Importance

Changes 5
Bugs 1 Features 0
Metric Value
c 5
b 1
f 0
dl 8
loc 29
rs 10
wmc 3
lcom 1
cbo 4

3 Methods

Rating   Name   Duplication   Size   Complexity  
A setupRules() 0 9 1
A getIdentifier() 0 4 1
A getMetadata() 8 8 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

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\Css;
17
18
19
use Kadet\Highlighter\Matcher\RegexMatcher;
20
use Kadet\Highlighter\Parser\Rule;
21
22
class Less extends PreProcessor
23
{
24
    /**
25
     * Tokenization rules
26
     */
27
    public function setupRules()
28
    {
29
        parent::setupRules();
30
        
31
        $this->rules->add('variable', new Rule(new RegexMatcher('/(@[\w-]+)/'), [
32
            'context'  => ['!comment', '!keyword'],
33
            'priority' => -1
34
        ]));
35
    }
36
37
    public function getIdentifier()
38
    {
39
        return 'less';
40
    }
41
42 View Code Duplication
    public static function getMetadata()
43
    {
44
        return [
45
            'name'      => ['less'],
46
            'mime'      => ['text/x-less'],
47
            'extension' => ['*.less']
48
        ];
49
    }
50
}
51