Passed
Push — master ( ed8f97...95efe5 )
by Chema
03:24
created

EdifactParser   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 12
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 6
dl 0
loc 12
ccs 6
cts 6
cp 1
rs 10
c 0
b 0
f 0
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A parse() 0 10 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace EdifactParser;
6
7
use EDI\Parser;
8
use EdifactParser\Exception\InvalidFile;
9
10
final class EdifactParser
11
{
12 3
    public static function parse(Parser $parser): TransactionResult
13
    {
14 3
        $errors = $parser->errors();
15
16 3
        if ($errors) {
0 ignored issues
show
Bug Best Practice introduced by
The expression $errors of type array is implicitly converted to a boolean; are you sure this is intended? If so, consider using ! empty($expr) instead to make it clear that you intend to check for an array without elements.

This check marks implicit conversions of arrays to boolean values in a comparison. While in PHP an empty array is considered to be equal (but not identical) to false, this is not always apparent.

Consider making the comparison explicit by using empty(..) or ! empty(...) instead.

Loading history...
17 1
            throw InvalidFile::withErrors($errors);
18
        }
19
20 2
        return TransactionResult::fromSegmentedValues(
21 2
            SegmentedValues::fromRaw($parser->get())
22
        );
23
    }
24
}
25