XmlParser   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
eloc 5
c 1
b 0
f 0
dl 0
loc 26
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A parse() 0 4 1
A __construct() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
/**
6
 * This file is part of slick/http
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Slick\Http\Message\Server\BodyParser;
13
14
use Psr\Http\Message\StreamInterface;
15
use Slick\Http\Message\Server\BodyParserInterface;
16
17
/**
18
 * XmlParser
19
 *
20
 * @package Slick\Http\Message\Server\BodyParser
21
*/
22
class XmlParser implements BodyParserInterface
23
{
24
    /**
25
     * @var StreamInterface
26
     */
27
    private $stream;
28
29
    /**
30
     * Creates a XML Body Parser
31
     *
32
     * @param StreamInterface $stream
33
     */
34
    public function __construct(StreamInterface $stream)
35
    {
36
        $this->stream = $stream;
37
    }
38
39
    /**
40
     * Parses the body as a XML document
41
     *
42
     * @return \SimpleXMLElement
43
     */
44
    public function parse()
45
    {
46
        $this->stream->rewind();
47
        return simplexml_load_string($this->stream->getContents());
48
    }
49
}
50