chillerlan / php-httpinterface

@@ -14,7 +14,7 @@
Loading
14 14
use Fig\Http\Message\RequestMethodInterface;
15 15
use Psr\Http\Message\{RequestFactoryInterface, RequestInterface};
16 16
17 -
class RequestFactory implements RequestFactoryInterface, RequestMethodInterface{
17 +
final class RequestFactory implements RequestFactoryInterface, RequestMethodInterface{
18 18
19 19
	/**
20 20
	 * @inheritDoc

@@ -293,7 +293,7 @@
Loading
293 293
		}
294 294
295 295
		// overwrite the default values with $curl_options
296 -
		foreach($this->options->curl_options as $k => $v){
296 +
		foreach($this->options->curl_options ?? [] as $k => $v){
297 297
			// skip some options that are only set automatically
298 298
			if(in_array($k, [CURLOPT_HTTPHEADER, CURLOPT_CUSTOMREQUEST, CURLOPT_NOBODY], true)){
299 299
				continue;
@@ -317,6 +317,7 @@
Loading
317 317
	 * @param int      $length
318 318
	 *
319 319
	 * @return string
320 +
	 * @noinspection PhpUnusedParameterInspection
320 321
	 */
321 322
	public function readfunction($curl, $stream, int $length):string{
322 323
		return $this->request->getBody()->read($length);
@@ -329,6 +330,7 @@
Loading
329 330
	 * @param string   $data
330 331
	 *
331 332
	 * @return int
333 +
	 * @noinspection PhpUnusedParameterInspection
332 334
	 */
333 335
	public function writefunction($curl, string $data):int{
334 336
		return $this->response->getBody()->write($data);
@@ -341,6 +343,7 @@
Loading
341 343
	 * @param string   $line
342 344
	 *
343 345
	 * @return int
346 +
	 * @noinspection PhpUnusedParameterInspection
344 347
	 */
345 348
	public function headerfunction($curl, string $line):int{
346 349
		$str    = trim($line);

@@ -14,7 +14,7 @@
Loading
14 14
use Psr\Http\Message\{StreamFactoryInterface, StreamInterface};
15 15
use InvalidArgumentException, RuntimeException;
16 16
17 -
use function fopen, in_array, is_file;
17 +
use function fopen, in_array, is_file, is_readable;
18 18
19 19
final class StreamFactory implements StreamFactoryInterface{
20 20
@@ -36,7 +36,7 @@
Loading
36 36
	 */
37 37
	public function createStreamFromFile(string $filename, string $mode = 'r'):StreamInterface{
38 38
39 -
		if(empty($filename) || !is_file($filename)){
39 +
		if(empty($filename) || !is_file($filename) || !is_readable($filename)){
40 40
			throw new RuntimeException('invalid file');
41 41
		}
42 42

@@ -63,20 +63,17 @@
Loading
63 63
			return '';
64 64
		}
65 65
66 -
		try{
66 +
		if($this->isSeekable()){
67 +
			$this->seek(0);
68 +
		}
67 69
68 -
			if($this->isSeekable()){
69 -
				$this->seek(0);
70 -
			}
70 +
		$contents = stream_get_contents($this->stream);
71 71
72 -
			return (string)stream_get_contents($this->stream);
73 -
		}
74 -
		// @codeCoverageIgnoreStart
75 -
		catch(Exception $e){
76 -
			throw new RuntimeException('Stream::__toString exception: '.$e->getMessage());
72 +
		if($contents !== false){
73 +
			return $contents;
77 74
		}
78 -
		// @codeCoverageIgnoreEnd
79 75
76 +
		throw new RuntimeException('stream_get_contents() error'); // @codeCoverageIgnore
80 77
	}
81 78
82 79
	/**
Files Complexity Coverage
src 379 74.64%
Project Totals (29 files) 379 74.64%
Notifications are pending CI completion. Waiting for GitHub's status webhook to queue notifications. Push notifications now.
Sunburst
The inner-most circle is the entire project, moving away from the center are folders then, finally, a single file. The size and color of each slice is representing the number of statements and the coverage, respectively.
Icicle
The top section represents the entire project. Proceeding with folders and finally individual files. The size and color of each slice is representing the number of statements and the coverage, respectively.
Grid
Each block represents a single file in the project. The size and color of each block is represented by the number of statements and the coverage, respectively.
Loading