| 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 Psr\Http\Message\StreamInterface; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10 |  |  | use ZBateson\StreamDecorators\Base64Stream; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11 |  |  | use ZBateson\StreamDecorators\CharsetStream; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 12 |  |  | use ZBateson\StreamDecorators\ChunkSplitStream; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 13 |  |  | use ZBateson\StreamDecorators\SeekingLimitStream; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 14 |  |  | use ZBateson\StreamDecorators\NonClosingStream; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 15 |  |  | use ZBateson\StreamDecorators\PregReplaceFilterStream; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 16 |  |  | use ZBateson\StreamDecorators\QuotedPrintableStream; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 17 |  |  | use ZBateson\StreamDecorators\UUStream; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 18 |  |  | use ZBateson\MailMimeParser\Message\Part\MessagePart; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 19 |  |  | use ZBateson\MailMimeParser\Message\Part\PartBuilder; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 20 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 21 |  |  | /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 22 |  |  |  * Factory class for Psr7 stream decorators used in MailMimeParser. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 23 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 24 |  |  |  * @author Zaahid Bateson | 
            
                                                                                                            
                            
            
                                    
            
            
                | 25 |  |  |  */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 26 |  |  | class StreamFactory | 
            
                                                                                                            
                            
            
                                    
            
            
                | 27 |  |  | { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 28 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 29 |  |  |      * Returns a SeekingLimitedStream using $part->getStreamPartLength() and | 
            
                                                                                                            
                            
            
                                    
            
            
                | 30 |  |  |      * $part->getStreamPartStartOffset() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 31 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 32 |  |  |      * @param StreamInterface $stream | 
            
                                                                                                            
                            
            
                                    
            
            
                | 33 |  |  |      * @param PartBuilder $part | 
            
                                                                                                            
                            
            
                                    
            
            
                | 34 |  |  |      * @return SeekingLimitedStream | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 35 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 36 | 1 |  |     public function getLimitedPartStream(StreamInterface $stream, PartBuilder $part) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 37 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 38 | 1 |  |         return $this->newLimitStream( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 39 | 1 |  |             $stream, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 40 | 1 |  |             $part->getStreamPartLength(), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 41 | 1 |  |             $part->getStreamPartStartOffset() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 42 |  |  |         ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 43 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 44 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 45 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 46 |  |  |      * Returns a SeekingLimitedStream using $part->getStreamContentLength() and | 
            
                                                                                                            
                            
            
                                    
            
            
                | 47 |  |  |      * $part->getStreamContentStartOffset() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 48 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 49 |  |  |      * @param StreamInterface $stream | 
            
                                                                                                            
                            
            
                                    
            
            
                | 50 |  |  |      * @param PartBuilder $part | 
            
                                                                                                            
                            
            
                                    
            
            
                | 51 |  |  |      * @return SeekingLimitedStream | 
            
                                                                                                            
                            
            
                                    
            
            
                | 52 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 53 | 1 |  |     public function getLimitedContentStream(StreamInterface $stream, PartBuilder $part) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 54 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 55 | 1 |  |         $length = $part->getStreamContentLength(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 56 | 1 |  |         if ($length !== 0) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 57 | 1 |  |             return $this->newLimitStream( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 58 | 1 |  |                 $stream, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 59 | 1 |  |                 $part->getStreamContentLength(), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 60 | 1 |  |                 $part->getStreamContentStartOffset() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 61 |  |  |             ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 62 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 63 | 1 |  |         return null; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 64 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 65 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 66 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 67 |  |  |      * Creates and returns a SeekingLimitedStream. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 68 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 69 |  |  |      * @param StreamInterface $stream | 
            
                                                                                                            
                            
            
                                    
            
            
                | 70 |  |  |      * @param int $length | 
            
                                                                                                            
                            
            
                                    
            
            
                | 71 |  |  |      * @param int $start | 
            
                                                                                                            
                            
            
                                    
            
            
                | 72 |  |  |      * @return SeekingLimitStream | 
            
                                                                                                            
                            
            
                                    
            
            
                | 73 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 74 | 1 |  |     private function newLimitStream(StreamInterface $stream, $length, $start) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 75 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 76 | 1 |  |         return new SeekingLimitStream( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 77 | 1 |  |             $this->newNonClosingStream($stream), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 78 | 1 |  |             $length, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 79 | 1 |  |             $start | 
            
                                                                                                            
                            
            
                                    
            
            
                | 80 |  |  |         ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 81 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 82 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 83 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 84 |  |  |      * Creates a non-closing stream that doesn't close it's internal stream when | 
            
                                                                                                            
                            
            
                                    
            
            
                | 85 |  |  |      * closing/detaching. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 86 |  |  |      *  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 87 |  |  |      * @param StreamInterface $stream | 
            
                                                                                                            
                            
            
                                    
            
            
                | 88 |  |  |      * @return NonClosingStream | 
            
                                                                                                            
                            
            
                                    
            
            
                | 89 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 90 | 1 |  |     public function newNonClosingStream(StreamInterface $stream) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 91 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 92 | 1 |  |         return new NonClosingStream($stream); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 93 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 94 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 95 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 96 |  |  |      * Creates a ChunkSplitStream. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 97 |  |  |      *  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 98 |  |  |      * @param StreamInterface $stream | 
            
                                                                                                            
                            
            
                                    
            
            
                | 99 |  |  |      * @return ChunkSplitStream | 
            
                                                                                                            
                            
            
                                    
            
            
                | 100 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 101 | 1 |  |     public function newChunkSplitStream(StreamInterface $stream) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 102 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 103 | 1 |  |         return new ChunkSplitStream($stream); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 104 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 105 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 106 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 107 |  |  |      * Creates and returns a Base64Stream with an internal | 
            
                                                                                                            
                            
            
                                    
            
            
                | 108 |  |  |      * PregReplaceFilterStream that filters out non-base64 characters. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 109 |  |  |      *  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 110 |  |  |      * @param StreamInterface $stream | 
            
                                                                                                            
                            
            
                                    
            
            
                | 111 |  |  |      * @return Base64Stream | 
            
                                                                                                            
                            
            
                                    
            
            
                | 112 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 113 | 1 |  |     public function newBase64Stream(StreamInterface $stream) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 114 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 115 | 1 |  |         return new Base64Stream( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 116 | 1 |  |             new PregReplaceFilterStream($stream, '/[^a-zA-Z0-9\/\+=]/', '') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 117 |  |  |         ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 118 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 119 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 120 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 121 |  |  |      * Creates and returns a QuotedPrintableStream. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 122 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 123 |  |  |      * @param StreamInterface $stream | 
            
                                                                                                            
                            
            
                                    
            
            
                | 124 |  |  |      * @return QuotedPrintableStream | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 125 |  |  |      */ | 
            
                                                                        
                            
            
                                    
            
            
                | 126 | 1 |  |     public function newQuotedPrintableStream(StreamInterface $stream) | 
            
                                                                        
                            
            
                                    
            
            
                | 127 |  |  |     { | 
            
                                                                        
                            
            
                                    
            
            
                | 128 | 1 |  |         return new QuotedPrintableStream($stream); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 129 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 130 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 131 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 132 |  |  |      * Creates and returns a UUStream | 
            
                                                                                                            
                            
            
                                    
            
            
                | 133 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 134 |  |  |      * @param StreamInterface $stream | 
            
                                                                                                            
                            
            
                                    
            
            
                | 135 |  |  |      * @return UUStream | 
            
                                                                                                            
                            
            
                                    
            
            
                | 136 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 137 | 1 |  |     public function newUUStream(StreamInterface $stream) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 138 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 139 | 1 |  |         return new UUStream($stream); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 140 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 141 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 142 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 143 |  |  |      * Creates and returns a CharsetStream | 
            
                                                                                                            
                            
            
                                    
            
            
                | 144 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 145 |  |  |      * @param StreamInterface $stream | 
            
                                                                                                            
                            
            
                                    
            
            
                | 146 |  |  |      * @param string $fromCharset | 
            
                                                                                                            
                            
            
                                    
            
            
                | 147 |  |  |      * @param string $toCharset | 
            
                                                                                                            
                            
            
                                    
            
            
                | 148 |  |  |      * @return CharsetStream | 
            
                                                                                                            
                            
            
                                    
            
            
                | 149 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 150 | 1 |  |     public function newCharsetStream(StreamInterface $stream, $fromCharset, $toCharset) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 151 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 152 | 1 |  |         return new CharsetStream($stream, $fromCharset, $toCharset); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 153 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 154 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 155 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 156 |  |  |      * Creates and returns a MessagePartStream | 
            
                                                                                                            
                            
            
                                    
            
            
                | 157 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 158 |  |  |      * @param MessagePart $part | 
            
                                                                                                            
                            
            
                                    
            
            
                | 159 |  |  |      * @return MessagePartStream | 
            
                                                                                                            
                            
            
                                    
            
            
                | 160 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 161 | 1 |  |     public function newMessagePartStream(MessagePart $part) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 162 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 163 | 1 |  |         return new MessagePartStream($this, $part); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 164 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 165 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 166 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 167 |  |  |      * Creates and returns a HeaderStream | 
            
                                                                                                            
                            
            
                                    
            
            
                | 168 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 169 |  |  |      * @param MessagePart $part | 
            
                                                                                                            
                            
            
                                    
            
            
                | 170 |  |  |      * @return HeaderStream | 
            
                                                                                                            
                            
            
                                    
            
            
                | 171 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 172 | 1 |  |     public function newHeaderStream(MessagePart $part) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 173 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 174 | 1 |  |         return new HeaderStream($part); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 175 |  |  |     } | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 176 |  |  | } | 
            
                                                        
            
                                    
            
            
                | 177 |  |  |  | 
            
                        
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