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

Factory   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 6

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 6
c 1
b 0
f 0
lcom 0
cbo 6
dl 0
loc 25
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
B createExpectation() 0 15 6
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