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

Scss   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 31
Duplicated Lines 25.81 %

Coupling/Cohesion

Components 1
Dependencies 4

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A setupRules() 0 11 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
use Kadet\Highlighter\Matcher\RegexMatcher;
19
use Kadet\Highlighter\Parser\Rule;
20
21
class Scss extends PreProcessor
22
{
23
    /**
24
     * Tokenization rules
25
     */
26
    public function setupRules()
27
    {
28
        parent::setupRules();
29
30
        $this->rules->remove('symbol.selector.tag');
31
        $this->rules->add('symbol.selector.tag', new Rule(new RegexMatcher('/(?>[\s{};]|^)(?=(\w+)[^;}]*\{)/m'), [
32
            'context' => ['!symbol', '!string', '!number']
33
        ]));
34
35
        $this->rules->add('variable', new Rule(new RegexMatcher('/(\$[\w-]+)/'), ['context' => $this->everywhere()]));
36
    }
37
38
    public function getIdentifier()
39
    {
40
        return 'scss';
41
    }
42
43 View Code Duplication
    public static function getMetadata()
44
    {
45
        return [
46
            'name'      => ['scss'],
47
            'mime'      => ['text/x-scss'],
48
            'extension' => ['*.scss']
49
        ];
50
    }
51
}
52