Completed
Push — master ( 634d7f...089f92 )
by Gabriel
02:37
created

Attachment   A

Complexity

Total Complexity 10

Size/Duplication

Total Lines 83
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 10
c 1
b 0
f 0
lcom 1
cbo 0
dl 0
loc 83
rs 10

8 Methods

Rating   Name   Duplication   Size   Complexity  
A setPath() 0 5 1
A getPath() 0 4 1
A setContent() 0 5 1
A getContent() 0 4 1
A setName() 0 5 1
A getName() 0 8 3
A setMimeType() 0 5 1
A getMimeType() 0 4 1
1
<?php
2
3
namespace Omnimail;
4
5
class Attachment implements AttachmentInterface
6
{
7
    protected $path;
8
    protected $name;
9
    protected $content;
10
    protected $mimeType;
11
12
    /**
13
     * @param string|null $path
14
     * @return AttachmentInterface
15
     */
16
    public function setPath($path = null)
17
    {
18
        $this->path = $path;
19
        return $this;
20
    }
21
22
    /**
23
     * @return string|null
24
     */
25
    public function getPath()
26
    {
27
        return $this->path;
28
    }
29
30
    /**
31
     * @param string|null $content
32
     * @return AttachmentInterface
33
     */
34
    public function setContent($content)
35
    {
36
        $this->content = $content;
37
        return $this;
38
    }
39
40
    /**
41
     * @return string|null
42
     */
43
    public function getContent()
44
    {
45
        return $this->content;
46
    }
47
48
    /**
49
     * @param string|null $name
50
     * @return AttachmentInterface
51
     */
52
    public function setName($name)
53
    {
54
        $this->name = $name;
55
        return $this;
56
    }
57
58
    /**
59
     * @return string|null
60
     */
61
    public function getName()
62
    {
63
        $name = $this->name;
64
        if (!$name && $this->path) {
0 ignored issues
show
Bug Best Practice introduced by
The expression $name of type string|null is loosely compared to false; this is ambiguous if the string can be empty. You might want to explicitly use === null instead.

In PHP, under loose comparison (like ==, or !=, or switch conditions), values of different types might be equal.

For string values, the empty string '' is a special case, in particular the following results might be unexpected:

''   == false // true
''   == null  // true
'ab' == false // false
'ab' == null  // false

// It is often better to use strict comparison
'' === false // false
'' === null  // false
Loading history...
Bug Best Practice introduced by
The expression $this->path of type string|null is loosely compared to true; this is ambiguous if the string can be empty. You might want to explicitly use !== null instead.

In PHP, under loose comparison (like ==, or !=, or switch conditions), values of different types might be equal.

For string values, the empty string '' is a special case, in particular the following results might be unexpected:

''   == false // true
''   == null  // true
'ab' == false // false
'ab' == null  // false

// It is often better to use strict comparison
'' === false // false
'' === null  // false
Loading history...
65
            return basename($this->path);
66
        }
67
        return $name;
68
    }
69
70
    /**
71
     * @param string|null $mimeType
72
     * @return AttachmentInterface
73
     */
74
    public function setMimeType($mimeType)
75
    {
76
        $this->mimeType = $mimeType;
77
        return $this;
78
    }
79
80
    /**
81
     * @return string|null
82
     */
83
    public function getMimeType()
84
    {
85
        return $this->mimeType;
86
    }
87
}
88