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

JsonParser   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 1
dl 0
loc 27
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
 * JsonParser
17
 *
18
 * @package Slick\Http\Message\Server\BodyParser
19
*/
20
class JsonParser implements BodyParserInterface
21
{
22
    /**
23
     * @var StreamInterface
24
     */
25
    private $stream;
26
27
    /**
28
     * Creates JsonParser
29
     * @param StreamInterface $stream
30
     */
31
    public function __construct(StreamInterface $stream)
32
    {
33
        $this->stream = $stream;
34
    }
35
36
    /**
37
     * Parses the provided
38
     *
39
     * @return mixed
40
     */
41
    public function parse()
42
    {
43
        $this->stream->rewind();
44
        return json_decode($this->stream->getContents());
45
    }
46
}