Mock   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 2
Bugs 0 Features 1
Metric Value
wmc 3
c 2
b 0
f 1
lcom 0
cbo 2
dl 0
loc 25
ccs 14
cts 14
cp 1
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A mock() 0 19 3
1
<?php
2
3
namespace Iris\Transfer;
4
5
class Mock
6
{
7
    /**
8
     * Creates a mock for a given transfer (because of dynamic getters and setters)
9
     */
10 19
    public static function mock($name, \PHPUnit_Framework_TestCase $phpunit)
0 ignored issues
show
Coding Style Best Practice introduced by
Please use __construct() instead of a PHP4-style constructor that is named after the class.
Loading history...
11
    {
12 19
        $methods = array();
13
14 19
        $ref = new \ReflectionClass($name);
15 19
        foreach ($ref->getProperties() as $property) {
16 17
            $methods[] = 'get' . ucfirst($property->name);
17 17
            $methods[] = 'set' . ucfirst($property->name);
18 19
        }
19
20 19
        foreach ($ref->getMethods() as $method) {
21 19
            $methods[] = $method->name;
22 19
        }
23
24 19
        return $phpunit->getMockBuilder($name)
25 19
            ->disableOriginalConstructor()
26 19
            ->setMethods($methods)
27 19
            ->getMock();
28
    }
29
}
30