Completed
Pull Request — master (#19)
by
unknown
08:16
created

ClassDocSniff   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 85
Duplicated Lines 34.12 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 1
dl 29
loc 85
ccs 11
cts 11
cp 1
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getListenedTokens() 0 8 1
B getTagMetadata() 0 26 1
B getDisallowedTags() 29 29 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
namespace BestIt\Sniffs\Commenting;
4
5
use BestIt\AbstractDocSniff;
6
7
/**
8
 * Class ClassDocSniff
9
 *
10
 * @package BestIt\Sniffs\Commenting
11
 * @author Nick Lubisch <[email protected]>
12
 */
13
class ClassDocSniff extends AbstractDocSniff
14
{
15
    /**
16
     * Returns which tokens should be listened to.
17
     *
18
     * @return array|int Tokens which should be listened to
19
     */
20 29
    public function getListenedTokens()
21
    {
22
        return [
23 29
            T_CLASS,
24 29
            T_INTERFACE,
25 29
            T_TRAIT
26
        ];
27
    }
28
29
    /**
30
     * Returns allowed tag metadata.
31
     *
32
     * The order in which they appear in this array os the order for tags needed.
33
     *
34
     * @return array List of tag metadata
35
     */
36 27
    public function getTagMetadata()
37
    {
38
        return [
39
            '@package' => [
40 27
                'min' => 1,
41 27
                'max' => 1,
42 27
                'if' => [$this->getTagHelper(), 'hasNamespace']
43 27
            ],
44
            '@author' => [
45
                'min' => 1,
46
                'max' => null
47
            ],
48
            '@version' => [
49
                'min' => 0,
50
                'max' => 1
51
            ],
52
            '@deprecated' => [
53
                'min' => 0,
54
                'max' => 1
55
            ],
56
            '@link' => [
57
                'min' => 0,
58
                'max' => null
59
            ]
60
        ];
61
    }
62
63
    /**
64
     * Returns an array of disallowed tokens.
65
     *
66
     * @return array List of disallowed tokens
67
     */
68 27 View Code Duplication
    public function getDisallowedTags()
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...
69
    {
70
        return [
71 27
            '@api',
72
            '@category',
73
            '@copyright',
74
            '@example',
75
            '@filesource',
76
            '@global',
77
            '@ignore',
78
            '@internal',
79
            '@license',
80
            '@method',
81
            '@param',
82
            '@property',
83
            '@property-read',
84
            '@property-write',
85
            '@return',
86
            '@see',
87
            '@since',
88
            '@source',
89
            '@subpackage',
90
            '@throws',
91
            '@todo',
92
            '@uses',
93
            '@var',
94
            '@inheritdoc'
95
        ];
96
    }
97
}
98