Mock::mock()   A
last analyzed

Complexity

Conditions 3
Paths 4

Size

Total Lines 19
Code Lines 12

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 14
CRAP Score 3

Importance

Changes 2
Bugs 0 Features 1
Metric Value
cc 3
eloc 12
c 2
b 0
f 1
nc 4
nop 2
dl 0
loc 19
ccs 14
cts 14
cp 1
crap 3
rs 9.4285
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