Completed
Push — master ( 089512...9dbb81 )
by Jimmy K. Oak
9s
created

EventSubscriberId   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 17
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 3
dl 0
loc 17
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A valueOrRandomOnNull() 0 4 2
1
<?php
2
3
namespace JimmyOak\Event;
4
5
use JimmyOak\DataType\SimpleValueObject;
6
use Ramsey\Uuid\Uuid;
7
8
class EventSubscriberId extends SimpleValueObject
9
{
10
    public function __construct($value = null)
11
    {
12
        parent::__construct($this->valueOrRandomOnNull($value));
13
    }
14
15
    /**
16
     * @param $value
17
     *
18
     * @return string
19
     */
20
    private function valueOrRandomOnNull($value)
21
    {
22
        return null === $value ? Uuid::uuid4()->toString() : $value;
23
    }
24
}