Completed
Push — master ( 4ea848...577058 )
by Hannes
02:16
created

Factory::createExpectation()   B

Complexity

Conditions 6
Paths 6

Size

Total Lines 15
Code Lines 12

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 15
rs 8.8571
cc 6
eloc 12
nc 6
nop 2
1
<?php
2
3
namespace hanneskod\readmetester\Expectation;
4
5
/**
6
 * Create expectations
7
 */
8
class Factory
9
{
10
    /**
11
     * Create expectations
12
     *
13
     * @param  string $name Name of expectation
14
     * @param  mixed  $data Expectation data
15
     * @return ExpectationInterface|null Null if no expectation could be created
16
     */
17
    public function createExpectation($name, $data)
18
    {
19
        switch (strtolower($name)) {
20
            case 'expectexception':
21
                return new ExceptionExpectation($data);
22
            case 'expectoutput':
23
                return new OutputExpectation(new Regexp($data));
24
            case 'expectreturntype':
25
                return new ReturnTypeExpectation($data);
26
            case 'expectreturn':
27
                return new ReturnExpectation(new Regexp($data));
28
            case 'expectnothing':
29
                return new NullExpectation;
30
        }
31
    }
32
}
33