GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

MockClass   A
last analyzed

Complexity

Total Complexity 12

Size/Duplication

Total Lines 109
Duplicated Lines 6.42 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 58.97%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 12
lcom 0
cbo 1
dl 7
loc 109
rs 10
c 1
b 0
f 0
ccs 23
cts 39
cp 0.5897

11 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A __destruct() 0 3 1
A __get() 0 3 1
A _toLog() 0 4 1
A getConstValue() 0 4 1
A sum() 0 4 1
A arrayTest() 7 7 1
A methodWithWrapper() 0 4 2
A arrayOfMockUser() 0 18 1
A noReturnFunction() 0 4 1
A voidReturnFunction() 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
 * MockClass
4
 *
5
 * @author Piotr Olaszewski <[email protected]>
6
 */
7
namespace Mocks;
8
9
use stdClass;
10
11
class MockClass
12
{
13 2
    public function __construct()
14
    {
15 2
    }
16
17
    public function __destruct()
18
    {
19
    }
20
21
    public function __get($name)
22
    {
23
    }
24
25
    /**
26
     * @desc MethodParser to logging
27
     * @param string $message
28
     */
29
    private function _toLog($message)
0 ignored issues
show
Unused Code introduced by
This method is not used, and could be removed.
Loading history...
30
    {
31
        file_put_contents('/tmp/logs_soap.log', $message);
32
    }
33
34
    public function getConstValue()
35
    {
36
        return 2;
37
    }
38
39
    /**
40
     * @WebMethod
41
     * @desc to sum two integers
42
     * @param int $a
43
     * @param int $b
44
     * @return int
45
     */
46 1
    public function sum($a, $b)
47
    {
48 1
        return $a + $b;
49
    }
50
51
    /**
52
     * @WebMethod
53
     * @param object $object1 @string=$name @int=$id
54
     * @return object $return @string=$new_name @int=$new_id
55
     */
56 View Code Duplication
    public function arrayTest($object1)
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...
57
    {
58
        $o = new stdClass();
59
        $o->new_name = 'new:' . $object1->name;
60
        $o->new_id = $object1->id + 2;
61
        return $o;
62
    }
63
64
    /**
65
     * @WebMethod
66
     * @param wrapper $wrap @className=\Mocks\MockUserWrapper
67
     * @return bool
68
     */
69
    public function methodWithWrapper($wrap)
70
    {
71
        return $wrap ? true : false;
72
    }
73
74
    /**
75
     * @WebMethod
76
     * @return wrapper[] $mockUsers @className=\Mocks\MockUserWrapper
77
     */
78 1
    public function arrayOfMockUser()
79
    {
80 1
        $mockUsers = array();
81
82 1
        $o = new MockUserWrapper();
83 1
        $o->id = 1;
84 1
        $o->name = 'Fred';
85 1
        $o->age = 20;
86 1
        $mockUsers[] = $o;
87
88 1
        $o = new MockUserWrapper();
89 1
        $o->id = 2;
90 1
        $o->name = 'Murray';
91 1
        $o->age = 25;
92 1
        $mockUsers[] = $o;
93
94 1
        return $mockUsers;
95
    }
96
97
    /**
98
     * @WebMethod
99
     * noReturnFunction
100
     *
101
     * @param int $a
102
     */
103 1
    public function noReturnFunction($a)
104
    {
105 1
        $a = $a + 1;
0 ignored issues
show
Unused Code introduced by
$a is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
106 1
    }
107
108
    /**
109
     * @WebMethod
110
     * voidReturnFunction
111
     *
112
     * @param int $a
113
     * @return void
114
     */
115 1
    public function voidReturnFunction($a)
116
    {
117 1
        $a = $a + 1;
0 ignored issues
show
Unused Code introduced by
$a is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
118 1
    }
119
}
120