HeaderCommonMethods   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 66
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 2
Bugs 0 Features 1
Metric Value
wmc 5
c 2
b 0
f 1
lcom 0
cbo 0
dl 0
loc 66
ccs 12
cts 12
cp 1
rs 10

6 Methods

Rating   Name   Duplication   Size   Complexity  
A getName() 0 4 1
A setName() 0 5 1
A getValue() 0 4 1
A setValue() 0 5 1
toString() 0 1 ?
A __toString() 0 4 1
1
<?php
2
3
/**
4
 * This file is part of slick/mail package
5
 *
6
 * For the full copyright and license information, please view the LICENSE
7
 * file that was distributed with this source code.
8
 */
9
10
namespace Slick\Mail\Header;
11
12
/**
13
 * Common methods for HeaderInterface objects
14
 *
15
 * @package Slick\Mail\Header
16
 * @author  Filipe Silva <[email protected]>
17
 */
18
trait HeaderCommonMethods
19
{
20
21
    /**
22
     * Gets header filed name
23
     *
24
     * @return string
25
     */
26 22
    public function getName()
27
    {
28 22
        return $this->name;
0 ignored issues
show
Bug introduced by
The property name does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
29
    }
30
31
    /**
32
     * Sets the header field name
33
     *
34
     * @param string $name
35
     *
36
     * @return AbstractHeader|$this|self
37
     */
38 16
    public function setName($name)
39
    {
40 16
        $this->name = $name;
41 16
        return $this;
42
    }
43
44
    /**
45
     * Gets header value
46
     *
47
     * @return string
48
     */
49 12
    public function getValue()
50
    {
51 12
        return $this->value;
0 ignored issues
show
Bug introduced by
The property value does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
52
    }
53
54
    /**
55
     * Sets the header value
56
     *
57
     * @param string $value
58
     *
59
     * @return AbstractHeader|$this|self
60
     */
61 16
    public function setValue($value)
62
    {
63 16
        $this->value = $value;
64 16
        return $this;
65
    }
66
67
    /**
68
     * Returns the string version of this header
69
     *
70
     * @return string
71
     */
72
    abstract public function toString();
73
74
    /**
75
     * An automated version of toString() method
76
     *
77
     * @return string
78
     */
79 16
    public function __toString()
80
    {
81 16
        return $this->toString();
82
    }
83
}