XmlParser::parse()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

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