Test Failed
Push — master ( 3a1416...95b80e )
by Banciu N. Cristian Mihai
02:31
created

MessageBuilder   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 74
Duplicated Lines 0 %

Importance

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

5 Methods

Rating   Name   Duplication   Size   Complexity  
A create() 0 3 1
A build() 0 9 1
A body() 0 5 1
A properties() 0 5 1
A headers() 0 5 1
1
<?php
2
3
namespace BinaryCube\CarrotMQ\Builder;
4
5
use Interop\Amqp\Impl\AmqpMessage;
6
7
/**
8
 * Class MessageBuilder
9
 *
10
 * @package BinaryCube\CarrotMQ\Builder
11
 */
12
class MessageBuilder
13
{
14
15
    /**
16
     * @var string
17
     */
18
    protected $body;
19
20
    /**
21
     * @var array
22
     */
23
    protected $properties = [];
24
25
    /**
26
     * @var array
27
     */
28
    protected $headers = [];
29
30
    /**
31
     * @return static
32
     */
33
    public static function create()
34
    {
35
        return new static();
36
    }
37
38
    /**
39
     * @param string $body
40
     *
41
     * @return $this
42
     */
43
    public function body(string $body)
44
    {
45
        $this->body = $body;
46
47
        return $this;
48
    }
49
50
    /**
51
     * @param array $properties
52
     *
53
     * @return $this
54
     */
55
    public function properties(array $properties)
56
    {
57
        $this->properties = $properties;
58
59
        return $this;
60
    }
61
62
    /**
63
     * @param array $headers
64
     *
65
     * @return $this
66
     */
67
    public function headers(array $headers)
68
    {
69
        $this->headers = $headers;
70
71
        return $this;
72
    }
73
74
    /**
75
     * @return AmqpMessage
76
     */
77
    public function build()
78
    {
79
        $message = new AmqpMessage();
80
81
        $message->setBody($this->body);
82
        $message->setProperties($this->properties);
83
        $message->setHeaders($this->headers);
84
85
        return $message;
86
    }
87
88
}
89