OutgoingPhysicalMessageMutationContext   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 59
Duplicated Lines 100 %

Coupling/Cohesion

Components 2
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 5
lcom 2
cbo 1
dl 59
loc 59
ccs 16
cts 16
cp 1
rs 10
c 0
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 7 7 1
A getBody() 4 4 1
A replaceBody() 6 6 1
A getHeaders() 4 4 1
A setHeader() 4 4 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php
2
namespace PSB\Core\MessageMutation\Pipeline\Outgoing;
3
4
5
use PSB\Core\Util\Guard;
6
7 View Code Duplication
class OutgoingPhysicalMessageMutationContext
8
{
9
    /**
10
     * @var string
11
     */
12
    private $body;
13
14
    /**
15
     * @var array
16
     */
17
    private $headers;
18
19
    /**
20
     * @param string $body
21
     * @param array  $headers
22
     */
23 8
    public function __construct($body, array $headers)
24
    {
25 8
        Guard::againstNull('body', $body);
26
27 7
        $this->body = $body;
28 7
        $this->headers = $headers;
29 7
    }
30
31
    /**
32
     * @return string
33
     */
34 3
    public function getBody()
35
    {
36 3
        return $this->body;
37
    }
38
39
    /**
40
     * @param string $newBody
41
     */
42 2
    public function replaceBody($newBody)
43
    {
44 2
        Guard::againstNull('body', $newBody);
45
46 1
        $this->body = $newBody;
47 1
    }
48
49
    /**
50
     * @return array
51
     */
52 3
    public function getHeaders()
53
    {
54 3
        return $this->headers;
55
    }
56
57
    /**
58
     * @param string $name
59
     * @param string $value
60
     */
61 1
    public function setHeader($name, $value)
62
    {
63 1
        $this->headers[$name] = $value;
64 1
    }
65
}
66