Passed
Push — master ( f8cb44...13b119 )
by Luis
04:20 queued 01:13
created

PhUmlStatisticsOptionTest   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 102
Duplicated Lines 95.1 %

Importance

Changes 0
Metric Value
dl 97
loc 102
rs 10
c 0
b 0
f 0
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A it_accepts_the_recursive_options_for_the_statistics_processor() 48 48 1
A it_shows_the_statistics_of_a_directory() 48 48 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
 * PHP version 7.1
4
 *
5
 * This source file is subject to the license that is bundled with this package in the file LICENSE.
6
 */
7
8
use PHPUnit\Framework\TestCase;
9
10
class PhUmlStatisticsOptionTest extends TestCase
11
{
12
    /** @test */
13 View Code Duplication
    function it_shows_the_statistics_of_a_directory()
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
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...
14
    {
15
        $statistics = <<<STATS
16
Phuml generated statistics
17
==========================
18
19
General statistics
20
------------------
21
22
Classes:    2
23
Interfaces: 0
24
25
Attributes: 3 (0 are typed)
26
    * private:   3
27
    * protected: 0
28
    * public:    0
29
30
Functions:  11 
31
    * private:   1
32
    * protected: 0
33
    * public:    10
34
35
Average statistics
36
------------------
37
38
Attributes per class: 1.5
39
Functions per class:  5.5
40
41
STATS;
42
        $output = <<<OUTPUT
43
phUML Version 0.2 (Jakob Westhoff <[email protected]>)
44
[|] Running... (This may take some time)
45
[|] Parsing class structure
46
[|] Running 'Statistics' processor
47
[|] Writing generated data to disk
48
49
OUTPUT;
50
        $file = __DIR__ . '/../../tests/.output/statistics.txt';
51
52
        passthru(sprintf(
53
            'php %s %s -statistics %s',
54
            __DIR__ . '/../../src/app/phuml',
55
            __DIR__ . '/../.code/classes',
56
            $file
57
        ));
58
59
        $this->expectOutputString($output);
60
        $this->assertStringEqualsFile($file, $statistics);
61
    }
62
63
    /** @test */
64 View Code Duplication
    function it_accepts_the_recursive_options_for_the_statistics_processor()
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
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
        $statistics = <<<STATS
67
Phuml generated statistics
68
==========================
69
70
General statistics
71
------------------
72
73
Classes:    19
74
Interfaces: 0
75
76
Attributes: 21 (0 are typed)
77
    * private:   16
78
    * protected: 1
79
    * public:    4
80
81
Functions:  86 
82
    * private:   36
83
    * protected: 0
84
    * public:    50
85
86
Average statistics
87
------------------
88
89
Attributes per class: 1.11
90
Functions per class:  4.53
91
92
STATS;
93
        $output = <<<OUTPUT
94
phUML Version 0.2 (Jakob Westhoff <[email protected]>)
95
[|] Running... (This may take some time)
96
[|] Parsing class structure
97
[|] Running 'Statistics' processor
98
[|] Writing generated data to disk
99
100
OUTPUT;
101
        $file = __DIR__ . '/../../tests/.output/statistics.txt';
102
103
        passthru(sprintf(
104
            'php %s -r %s -statistics %s',
105
            __DIR__ . '/../../src/app/phuml',
106
            __DIR__ . '/../.code/classes',
107
            $file
108
        ));
109
110
        $this->expectOutputString($output);
111
        $this->assertStringEqualsFile($file, $statistics);
112
    }
113
}
114