Slim   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 8
c 1
b 0
f 0
dl 0
loc 21
rs 10
wmc 3

1 Method

Rating   Name   Duplication   Size   Complexity  
A createStream() 0 11 3
1
<?php
2
3
/**
4
 * @license LGPLv3, http://opensource.org/licenses/LGPL-3.0
5
 * @copyright Aimeos (aimeos.org), 2016-2020
6
 * @package MW
7
 * @subpackage View
8
 */
9
10
11
namespace Aimeos\MW\View\Helper\Response;
12
13
use Psr\Http\Message\StreamInterface;
14
15
16
/**
17
 * View helper class for setting response data
18
 *
19
 * @package MW
20
 * @subpackage View
21
 */
22
class Slim
23
	extends \Aimeos\MW\View\Helper\Response\Standard
24
	implements \Aimeos\MW\View\Helper\Response\Iface
25
{
26
	/**
27
	 * Creates a new PSR-7 stream object
28
	 *
29
	 * @param string|resource Absolute file path or file descriptor
0 ignored issues
show
Bug introduced by
The type Aimeos\MW\View\Helper\Response\Absolute was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
30
	 * @return \Psr\Http\Message\StreamInterface Stream object
31
	 */
32
	public function createStream( $resource ) : \Psr\Http\Message\StreamInterface
33
	{
34
		if( is_resource( $resource ) === true ) {
35
			return new \Slim\Http\Stream( $resource );
36
		}
37
38
		if( ( $fh = @fopen( $resource, 'r' ) ) !== false ) {
39
			return new \Slim\Http\Stream( $fh );
40
		}
41
42
		throw new \Aimeos\MW\Exception( sprintf( 'Unable to open file "%1$s"', $resource ) );
43
	}
44
}
45