ParserAware   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 6
c 2
b 0
f 0
dl 0
loc 20
rs 10
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getParser() 0 6 2
A setParser() 0 3 1
1
<?php
2
3
namespace PhpXmlRpc\Traits;
4
5
use PhpXmlRpc\Helper\XMLParser;
6
7
/**
8
 * NB: if a class implements this trait, and it is subclassed, instances of the class and of the subclass will share
9
 * the same parser instance, unless the subclass reimplements these methods
10
 */
11
trait ParserAware
12
{
13
    protected static $parser;
14
15
    /// @todo feature-creep: allow passing in $options (but then, how to deal with changing options between invocations?)
16
    public function getParser()
17
    {
18
        if (self::$parser === null) {
19
            self::$parser = new XMLParser();
20
        }
21
        return self::$parser;
22
    }
23
24
    /**
25
     * @param $parser
26
     * @return void
27
     */
28
    public static function setParser($parser)
29
    {
30
        self::$parser = $parser;
31
    }
32
}
33