Message::__construct()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 1
Metric Value
c 2
b 0
f 1
dl 0
loc 8
rs 9.4285
cc 2
eloc 4
nc 2
nop 2
1
<?php
2
3
namespace R\Hive\Concrete\Data;
4
5
use R\Hive\Contracts\Data\MessageInterface;
6
use R\Hive\Contracts\Data\ValidatorInterface;
7
8
class Message implements MessageInterface
9
{
10
    protected $message;
11
    protected $validator;
12
13
    public function __construct($message, ValidatorInterface $validator = null)
14
    {
15
        $this->message = $message;
16
17
        if ($validator !== null) {
18
            $this->attachValidator($validator);
19
        }
20
    }
21
22
    public function attachValidator(ValidatorInterface $validator)
23
    {
24
        $this->validator = $validator;
25
    }
26
27
    public function getMessage()
28
    {
29
        return $this->message;
30
    }
31
32
    public function getValidator()
33
    {
34
        return $this->validator;
35
    }
36
37
    public function hasValidator()
38
    {
39
        return $this->validator !== null;
40
    }
41
}
42