Test Failed
Push — master ( e258e4...a626ba )
by Zaahid
15:25
created

MessagePartStreamReadException   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 16
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
eloc 5
c 1
b 0
f 0
dl 0
loc 16
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A getPart() 0 3 1
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
8
namespace ZBateson\MailMimeParser\Stream;
9
10
use RuntimeException;
11
use ZBateson\MailMimeParser\Message\IMessagePart;
12
13
/**
14
 * Thrown for exceptions on MessagePartStream::read so a $part can be used to
15
 * determine where the exception occurred.
16
 *
17
 * @author Zaahid Bateson
18
 */
19
class MessagePartStreamReadException extends RuntimeException
20
{
21
    /**
22
     * @var IMessagePart the IMessagePart the error was caused on.
23
     */
24
    protected IMessagePart $part;
25
26
    public function __construct(IMessagePart $part, string $message = "", int $code = 0, ?\Throwable $previous = null)
0 ignored issues
show
Coding Style Comprehensibility introduced by
The string literal does not require double quotes, as per coding-style, please use single quotes.

PHP provides two ways to mark string literals. Either with single quotes 'literal' or with double quotes "literal". The difference between these is that string literals in double quotes may contain variables with are evaluated at run-time as well as escape sequences.

String literals in single quotes on the other hand are evaluated very literally and the only two characters that needs escaping in the literal are the single quote itself (\') and the backslash (\\). Every other character is displayed as is.

Double quoted string literals may contain other variables or more complex escape sequences.

<?php

$singleQuoted = 'Value';
$doubleQuoted = "\tSingle is $singleQuoted";

print $doubleQuoted;

will print an indented: Single is Value

If your string literal does not contain variables or escape sequences, it should be defined using single quotes to make that fact clear.

For more information on PHP string literals and available escape sequences see the PHP core documentation.

Loading history...
27
    {
28
        parent::__construct($message, $code, $previous);
29
        $this->part = $part;
30
    }
31
32
    public function getPart() : IMessagePart
33
    {
34
        return $this->part;
35
    }
36
}
37