Completed
Push — master ( c1a156...8cadde )
by Kirill
08:14
created

JsonLanguage   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 42
Duplicated Lines 54.76 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
dl 23
loc 42
ccs 0
cts 27
cp 0
rs 10
c 0
b 0
f 0
wmc 3
lcom 0
cbo 1

3 Methods

Rating   Name   Duplication   Size   Complexity  
A tokens() 12 12 1
A colors() 11 11 1
A match() 0 4 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
 * This file is part of Railt package.
4
 *
5
 * For the full copyright and license information, please view the LICENSE
6
 * file that was distributed with this source code.
7
 */
8
declare(strict_types=1);
9
10
namespace Railt\SDL\Console\Language;
11
12
use Railt\Console\Language\Language;
13
use Railt\Io\Readable;
14
15
/**
16
 * Class JsonLanguage
17
 */
18
class JsonLanguage extends Language
19
{
20
    /**
21
     * @return array
22
     */
23 View Code Duplication
    public function tokens(): array
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
24
    {
25
        return [
26
            'T_STRING'  => '"[^"\\\\]*(\\\\.[^"\\\\]*)*"(?!:)',
27
            'T_KEY'     => '"[^"\\\\]*(\\\\.[^"\\\\]*)*"',
28
            'T_DIGIT'   => '(\d*\.)?\d+',
29
            'T_COMMA'   => ',',
30
            'T_ARR'     => '\[\]',
31
            'T_KEYWORD' => 'null|false|true',
32
            'T_PAIR'    => '[{:}]',
33
        ];
34
    }
35
36
    /**
37
     * @return array
38
     */
39 View Code Duplication
    public function colors(): array
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
40
    {
41
        return [
42
            'T_KEY'     => 'fg=green',
43
            'T_STRING'  => 'fg=yellow',
44
            'T_COMMA'   => 'fg=blue',
45
            'T_KEYWORD' => 'fg=yellow',
46
            'T_ARR'     => 'fg=yellow',
47
            'T_PAIR'    => 'fg=blue;options=bold',
48
        ];
49
    }
50
51
    /**
52
     * @param Readable $file
53
     * @return bool
54
     */
55
    public function match(Readable $file): bool
56
    {
57
        return $this->matchExtension($file, ['json']);
58
    }
59
}
60