StringStream::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 7
ccs 6
cts 6
cp 1
rs 9.4285
cc 1
eloc 5
nc 1
nop 1
crap 1
1
<?php
2
namespace Kambo\Http\Stream;
3
4
// \Spl
5
use RuntimeException;
6
use Exception;
7
8
// \Psr
9
use Psr\Http\Message\StreamInterface;
10
11
// \Http\Message
12
use Kambo\Http\Message\Stream;
13
14
/**
15
 * Describes a data stream, instantiate using string.
16
 *
17
 * It provides a wrapper around the most common operations, including serialization of
18
 * the entire stream to a string.
19
 *
20
 * @package Kambo\Http\Stream
21
 * @author  Bohuslav Simek <[email protected]>
22
 * @license MIT
23
 */
24
class StringStream extends Stream
25
{
26
    /**
27
     * Constructor
28
     *
29
     * @param string $content
30
     */
31 1
    public function __construct($content)
32
    {
33 1
        $stringResource = fopen('php://temp', 'r+');
34 1
        fwrite($stringResource, $content);
35 1
        rewind($stringResource);
36 1
        parent::__construct($stringResource);
37 1
    }
38
}
39