PostTitleWasChanged::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

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

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...
36
    }
37
38
    /**
39
     * @return PostId
40
     */
41
    public function id()
42
    {
43
        return $this->aggregateId();
44
    }
45
46
    /**
47
     * @return string
48
     */
49
    public function title()
50
    {
51
        return $this->getPayload('title');
0 ignored issues
show
Bug introduced by
The method getPayload() does not seem to exist on object<Cubiche\Domain\Ev...nt\PostTitleWasChanged>.

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...
52
    }
53
54
    /**
55
     * {@inheritdoc}
56
     */
57
    public static function loadValidatorMetadata(ClassMetadata $classMetadata)
58
    {
59
        $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...
60
    }
61
}
62