Passed
Pull Request — master (#19)
by
unknown
02:19
created

MethodDocSniff   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 83
Duplicated Lines 34.94 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 100%

Importance

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

3 Methods

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