BestParserDelegate   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 2
dl 0
loc 31
ccs 0
cts 11
cp 0
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A parse() 0 6 2
1
<?php
2
3
namespace Fxmlrpc\Serialization\Parser;
4
5
use Fxmlrpc\Serialization\Parser;
6
7
/**
8
 * Parser that selects the best available parser.
9
 *
10
 * @author Lars Strojny <[email protected]>
11
 */
12
final class BestParserDelegate implements Parser
13
{
14
    /**
15
     * @var NativeParser
16
     */
17
    private $nativeParser;
18
19
    /**
20
     * @var XmlReaderParser
21
     */
22
    private $xmlReaderParser;
23
24
    /**
25
     * @param bool $validateResponse
26
     */
27
    public function __construct($validateResponse = true)
28
    {
29
        $this->nativeParser = new NativeParser($validateResponse);
30
        $this->xmlReaderParser = new XmlReaderParser($validateResponse);
31
    }
32
33
    /**
34
     * {@inheritdoc}
35
     */
36
    public function parse($xmlString)
37
    {
38
        return !NativeParser::isBiggerThanParseLimit($xmlString)
39
            ? $this->nativeParser->parse($xmlString)
40
            : $this->xmlReaderParser->parse($xmlString);
41
    }
42
}
43