TestResultFactory   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 4

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 5
lcom 0
cbo 4
dl 0
loc 22
ccs 10
cts 10
cp 1
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A createFromLog() 0 19 5
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Paraunit\TestResult;
6
7
use Paraunit\Parser\JSON\LogFetcher;
8
use Paraunit\TestResult\Interfaces\PrintableTestResultInterface;
9
10
/**
11
 * Class TestResultFactory
12
 * @package Paraunit\TestResult
13
 */
14
class TestResultFactory
15
{
16 41
    public function createFromLog(\stdClass $log): PrintableTestResultInterface
17
    {
18 41
        if (property_exists($log, 'status') && $log->status === LogFetcher::LOG_ENDING_STATUS) {
19 13
            return new TestResultWithAbnormalTermination(
20 13
                $log->test,
21 13
                'Abnormal termination -- complete test output:'
22
            );
23
        }
24
25 35
        if (! property_exists($log, 'message')) {
26 5
            return new MuteTestResult();
27
        }
28
29 32
        if (property_exists($log, 'trace')) {
30 31
            return new FullTestResult($log->test, $log->message, $log->trace);
31
        }
32
33 1
        return new TestResultWithMessage($log->test, $log->message);
34
    }
35
}
36