1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* This file is part of the ZBateson\MailMimeParser project. |
4
|
|
|
* |
5
|
|
|
* @license http://opensource.org/licenses/bsd-license.php BSD |
6
|
|
|
*/ |
7
|
|
|
namespace ZBateson\MailMimeParser\Stream; |
8
|
|
|
|
9
|
|
|
use ZBateson\MailMimeParser\Message\Part\ParentHeaderPart; |
10
|
|
|
use ZBateson\MailMimeParser\Message\Part\MessagePart; |
11
|
|
|
use Psr\Http\Message\StreamInterface; |
12
|
|
|
use GuzzleHttp\Psr7\StreamDecoratorTrait; |
13
|
|
|
use GuzzleHttp\Psr7; |
14
|
|
|
|
15
|
|
|
/** |
16
|
|
|
* |
17
|
|
|
* |
18
|
|
|
* @author Zaahid Bateson |
19
|
|
|
*/ |
20
|
|
|
class HeaderStream implements StreamInterface |
21
|
|
|
{ |
22
|
|
|
use StreamDecoratorTrait; |
23
|
|
|
|
24
|
|
|
protected $part; |
25
|
|
|
|
26
|
|
|
public function __construct(MessagePart $part) |
27
|
|
|
{ |
28
|
|
|
$this->part = $part; |
29
|
|
|
} |
30
|
|
|
|
31
|
|
|
private function getPartHeadersArray() |
32
|
|
|
{ |
33
|
|
|
if ($this->part instanceof ParentHeaderPart) { |
34
|
|
|
return $this->part->getRawHeaders(); |
35
|
|
|
} elseif ($this->part->getParent() !== null && $this->part->getParent()->isMime()) { |
36
|
|
|
return [ |
37
|
|
|
[ 'Content-Type', $this->part->getContentType() ], |
38
|
|
|
[ 'Content-Disposition', $this->part->getContentDisposition() ], |
39
|
|
|
[ 'Content-Transfer-Encoding', $this->part->getContentTransferEncoding() ] |
40
|
|
|
]; |
41
|
|
|
} |
42
|
|
|
return []; |
43
|
|
|
} |
44
|
|
|
|
45
|
|
|
/** |
46
|
|
|
* Writes out the headers of the passed part and follows them with an |
47
|
|
|
* empty line. |
48
|
|
|
* |
49
|
|
|
* @param MimePart $part |
|
|
|
|
50
|
|
|
* @param StreamInterface $stream |
51
|
|
|
*/ |
52
|
|
|
public function writePartHeadersTo(StreamInterface $stream) |
53
|
|
|
{ |
54
|
|
|
$headers = $this->getPartHeadersArray($this->part); |
|
|
|
|
55
|
|
|
foreach ($headers as $header) { |
56
|
|
|
$stream->write("${header[0]}: ${header[1]}\r\n"); |
57
|
|
|
} |
58
|
|
|
$stream->write("\r\n"); |
59
|
|
|
} |
60
|
|
|
|
61
|
|
|
/** |
62
|
|
|
* Creates the underlying stream lazily when required. |
63
|
|
|
* |
64
|
|
|
* @return StreamInterface |
65
|
|
|
*/ |
66
|
|
|
protected function createStream() |
67
|
|
|
{ |
68
|
|
|
$stream = Psr7\stream_for(); |
|
|
|
|
69
|
|
|
$this->writePartHeadersTo($stream); |
70
|
|
|
$stream->rewind(); |
71
|
|
|
return $stream; |
72
|
|
|
} |
73
|
|
|
} |
74
|
|
|
|
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:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths