EventSubscriberId::valueOrRandomOnNull()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

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