PostWasCreated   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 50
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

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

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 7 1
A id() 0 4 1
A title() 0 4 1
A content() 0 4 1
A loadValidatorMetadata() 0 5 1
1
<?php
2
3
/**
4
 * This file is part of the Cubiche package.
5
 *
6
 * Copyright (c) Cubiche
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Cubiche\Domain\EventSourcing\Tests\Fixtures\Event;
13
14
use Cubiche\Core\Validator\Assert;
15
use Cubiche\Core\Validator\Mapping\ClassMetadata;
16
use Cubiche\Domain\EventSourcing\DomainEvent;
17
use Cubiche\Domain\Model\Tests\Fixtures\PostId;
18
19
/**
20
 * PostWasCreated class.
21
 *
22
 * @author Ivannis Suárez Jerez <[email protected]>
23
 */
24
class PostWasCreated extends DomainEvent
25
{
26
    /**
27
     * PostWasCreated constructor.
28
     *
29
     * @param PostId $id
30
     * @param string $title
31
     * @param string $content
32
     */
33
    public function __construct(PostId $id, $title, $content)
34
    {
35
        parent::__construct($id);
36
37
        $this->setPayload('title', $title);
0 ignored issues
show
Bug introduced by
The method setPayload() does not seem to exist on object<Cubiche\Domain\Ev...s\Event\PostWasCreated>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
38
        $this->setPayload('content', $content);
0 ignored issues
show
Bug introduced by
The method setPayload() does not seem to exist on object<Cubiche\Domain\Ev...s\Event\PostWasCreated>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
39
    }
40
41
    /**
42
     * @return PostId
43
     */
44
    public function id()
45
    {
46
        return $this->aggregateId();
47
    }
48
49
    /**
50
     * @return string
51
     */
52
    public function title()
53
    {
54
        return $this->getPayload('title');
0 ignored issues
show
Bug introduced by
The method getPayload() does not seem to exist on object<Cubiche\Domain\Ev...s\Event\PostWasCreated>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
55
    }
56
57
    /**
58
     * @return string
59
     */
60
    public function content()
61
    {
62
        return $this->getPayload('content');
0 ignored issues
show
Bug introduced by
The method getPayload() does not seem to exist on object<Cubiche\Domain\Ev...s\Event\PostWasCreated>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
63
    }
64
65
    /**
66
     * {@inheritdoc}
67
     */
68
    public static function loadValidatorMetadata(ClassMetadata $classMetadata)
69
    {
70
        $classMetadata->addMethodConstraint('title', Assert::stringType()->notBlank());
0 ignored issues
show
Bug introduced by
The method addMethodConstraint() does not seem to exist on object<Cubiche\Core\Vali...\Mapping\ClassMetadata>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
71
        $classMetadata->addMethodConstraint('content', Assert::stringType());
0 ignored issues
show
Bug introduced by
The method addMethodConstraint() does not seem to exist on object<Cubiche\Core\Vali...\Mapping\ClassMetadata>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
72
    }
73
}
74