UnexpectedTagException   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 100%

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 21 4
1
<?php
2
3
namespace Fxmlrpc\Serialization\Exception;
4
5
/**
6
 * @author Lars Strojny <[email protected]>
7
 */
8
final class UnexpectedTagException extends ParserException
9
{
10
    /**
11
     * @param string $tagName
12
     * @param mixed  $elements
13
     * @param array  $definedVariables
14
     * @param int    $depth
15
     * @param string $xml
16
     */
17 3
    public function __construct($tagName, $elements, array $definedVariables, $depth, $xml)
18
    {
19 3
        $expectedElements = [];
20 3
        foreach ($definedVariables as $variableName => $variable) {
21 3
            if (substr($variableName, 0, 4) !== 'flag') {
22 3
                continue;
23
            }
24
25 3
            if (($elements & $variable) === $variable) {
26 3
                $expectedElements[] = substr($variableName, 4);
27 3
            }
28 3
        }
29
30 3
        $this->message = sprintf(
31 3
            'Invalid XML. Expected one of "%s", got "%s" on depth %d (context: "%s")',
32 3
            implode('", "', $expectedElements),
33 3
            $tagName,
34 3
            $depth,
35
            $xml
36 3
        );
37 3
    }
38
}
39