Passed
Pull Request — master (#171)
by Zaahid
07:14 queued 03:53
created

UUEncodedPart::setUnixFileMode()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
eloc 2
c 0
b 0
f 0
dl 0
loc 4
ccs 3
cts 3
cp 1
rs 10
cc 1
nc 1
nop 1
crap 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
namespace ZBateson\MailMimeParser\Message;
8
9
use ZBateson\MailMimeParser\Message\PartStreamContainer;
10
11
/**
12
 * Implementation of a non-mime message's uuencoded attachment part.
13
 *
14
 * @author Zaahid Bateson
15
 */
16
class UUEncodedPart extends NonMimePart implements IUUEncodedPart
17
{
18
    /**
19
     * @var int the unix file permission
20
     */
21
    protected $mode = null;
22
23
    /**
24
     * @var string the name of the file in the uuencoding 'header'.
25
     */
26
    protected $filename = null;
27
28 10
    public function __construct($mode = null, $filename = null, IMimePart $parent = null, PartStreamContainer $streamContainer = null)
29
    {
30 10
        if ($streamContainer === null) {
31
            $di = MailMimeParser::getDependencyContainer();
0 ignored issues
show
Bug introduced by
The type ZBateson\MailMimeParser\Message\MailMimeParser 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...
32
            $streamContainer = $di['ZBateson\MailMimeParser\Message\PartStreamContainer'];
33
            $streamFactory = $di['ZBateson\MailMimeParser\Stream\StreamFactory'];
34
            $streamContainer->setStream($streamFactory->newMessagePartStream($this));
35
        }
36 10
        parent::__construct(
37 10
            $streamContainer,
38 10
            $parent
39
        );
40 10
        $this->mode = $mode;
41 10
        $this->filename = $filename;
42 10
    }
43
44
    /**
45
     * Returns the filename included in the uuencoded 'begin' line for this
46
     * part.
47
     *
48
     * @return string
49
     */
50 4
    public function getFilename()
51
    {
52 4
        return $this->filename;
53
    }
54
55 1
    public function setFilename($filename)
56
    {
57 1
        $this->filename = $filename;
58 1
        $this->notify();
59 1
    }
60
61
    /**
62
     * Returns false.
63
     * 
64
     * Although the part may be plain text, there is no reliable way of
65
     * determining its type since uuencoded 'begin' lines only include a file
66
     * name and no mime type.  The file name's extension may be a hint.
67
     * 
68
     * @return bool
69
     */
70 3
    public function isTextPart()
71
    {
72 3
        return false;
73
    }
74
75
    /**
76
     * Returns 'application/octet-stream'.
77
     * 
78
     * @return string
79
     */
80 4
    public function getContentType($default = 'application/octet-stream')
81
    {
82 4
        return 'application/octet-stream';
83
    }
84
85
    /**
86
     * Returns null
87
     * 
88
     * @return string
89
     */
90 4
    public function getCharset()
91
    {
92 4
        return null;
93
    }
94
95
    /**
96
     * Returns 'attachment'.
97
     * 
98
     * @return string
99
     */
100 3
    public function getContentDisposition($default = 'attachment')
101
    {
102 3
        return 'attachment';
103
    }
104
105
    /**
106
     * Returns 'x-uuencode'.
107
     * 
108
     * @return string
109
     */
110 3
    public function getContentTransferEncoding($default = 'x-uuencode')
111
    {
112 3
        return 'x-uuencode';
113
    }
114
115 1
    public function getUnixFileMode()
116
    {
117 1
        return $this->mode;
118
    }
119
120 1
    public function setUnixFileMode($mode)
121
    {
122 1
        $this->mode = $mode;
123 1
        $this->notify();
124 1
    }
125
}
126