Message::attachValidator()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 1
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