Test Failed
Push — master ( 57b7d4...e042c7 )
by Hannes
02:15
created

ExpectationFactory   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 13
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
dl 0
loc 13
rs 10
c 0
b 0
f 0
wmc 5

1 Method

Rating   Name   Duplication   Size   Complexity  
B createExpectation() 0 11 5
1
<?php
2
3
declare(strict_types = 1);
4
5
namespace hanneskod\readmetester\Expectation;
6
7
use hanneskod\readmetester\Annotations;
8
use hanneskod\readmetester\Parser\Annotation;
9
10
/**
11
 * Create expectations from annotation data
12
 */
13
class ExpectationFactory
14
{
15
    public function createExpectation(Annotation $annotation): ?ExpectationInterface
16
    {
17
        if ($annotation->isNamed(Annotations::ANNOTATION_EXPECT_OUTPUT)) {
18
            return new OutputExpectation(new Regexp($annotation->getArgument() ?: '//'));
19
        }
20
21
        if ($annotation->isNamed(Annotations::ANNOTATION_EXPECT_ERROR)) {
22
            return new ErrorExpectation(new Regexp($annotation->getArgument() ?: '//'));
23
        }
24
25
        return null;
26
    }
27
}
28