Message   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 3
Bugs 0 Features 1
Metric Value
wmc 6
c 3
b 0
f 1
lcom 1
cbo 0
dl 0
loc 34
rs 10

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 8 2
A attachValidator() 0 4 1
A getMessage() 0 4 1
A getValidator() 0 4 1
A hasValidator() 0 4 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