Completed
Push — master ( 6b8416...c520c0 )
by Filipe
02:12
created

FileStream   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 10 2
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\Stream;
11
12
use Psr\Http\Message\StreamInterface;
13
use Slick\Http\Message\Exception\InvalidArgumentException;
14
15
/**
16
 * File Stream
17
 *
18
 * @package Slick\Http\Message\Stream
19
 */
20
class FileStream extends AbstractStream implements StreamInterface
21
{
22
23
    /**
24
     * Creates a File Stream
25
     *
26
     * @param string $file The file FQ name to create the stream from
27
     *
28
     * @throws InvalidArgumentException If provided file does not exists
29
     */
30
    public function __construct($file)
31
    {
32
        if (! is_file($file)) {
33
            throw new InvalidArgumentException(
34
                "Cannot create stream: given file is not found."
35
            );
36
        }
37
38
        $this->stream = fopen($file, 'r');
39
    }
40
}