Completed
Branch master (c520c0)
by Filipe
01:29
created

XmlParser   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 1
dl 0
loc 28
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A parse() 0 5 1
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
}