CategoryWasCreated   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 41
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 14
dl 0
loc 41
rs 10
c 0
b 0
f 0
wmc 5

3 Methods

Rating   Name   Duplication   Size   Complexity  
A createWithData() 0 11 1
A getName() 0 7 2
A getId() 0 7 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace App\Domain\Category\Events;
6
7
use App\Domain\Common\ValueObject\AggregateRootId;
8
use App\Domain\Common\ValueObject\Name;
9
use Prooph\EventSourcing\AggregateChanged;
0 ignored issues
show
Bug introduced by
The type Prooph\EventSourcing\AggregateChanged was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
10
11
final class CategoryWasCreated extends AggregateChanged
12
{
13
    /**
14
     * @var AggregateRootId
15
     */
16
    private $id;
17
18
    /**
19
     * @var Name
20
     */
21
    private $name;
22
23
    public static function createWithData(AggregateRootId $id, Name $name): self
24
    {
25
        /** @var self $event */
26
        $event = self::occur($id->toString(), [
27
            'name' => $name->toString(),
28
        ]);
29
30
        $event->id = $id;
31
        $event->name = $name;
32
33
        return $event;
34
    }
35
36
    public function getId(): AggregateRootId
37
    {
38
        if (null === $this->id) {
39
            $this->id = AggregateRootId::fromString($this->aggregateId());
40
        }
41
42
        return $this->id;
43
    }
44
45
    public function getName(): Name
46
    {
47
        if (null === $this->name) {
48
            $this->name = Name::fromString($this->payload['name']);
49
        }
50
51
        return $this->name;
52
    }
53
}
54