GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Push — bugfix/5.4build ( 31a631 )
by Szurovecz
08:38
created

AbstractDomainEvent   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 56
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 6

Importance

Changes 11
Bugs 1 Features 1
Metric Value
wmc 6
c 11
b 1
f 1
lcom 1
cbo 6
dl 0
loc 56
rs 10

5 Methods

Rating   Name   Duplication   Size   Complexity  
A initEvent() 0 6 1
A __construct() 0 8 2
A aggregateId() 0 4 1
A toStringHelper() 0 6 1
A setAggregateId() 0 5 1
1
<?php
2
/*
3
 * Copyright (c) 2013 Janos Szurovecz
4
 *
5
 * Permission is hereby granted, free of charge, to any person obtaining a copy of
6
 * this software and associated documentation files (the "Software"), to deal in
7
 * the Software without restriction, including without limitation the rights to
8
 * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
9
 * of the Software, and to permit persons to whom the Software is furnished to do
10
 * so, subject to the following conditions:
11
 *
12
 * The above copyright notice and this permission notice shall be included in all
13
 * copies or substantial portions of the Software.
14
 *
15
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
 * SOFTWARE.
22
 */
23
24
namespace predaddy\domain;
25
26
use predaddy\messagehandling\AbstractMessage;
27
28
/**
29
 * Base class for all Domain Events.
30
 * This class contains the basic behavior expected from any event
31
 * to be processed by event sourcing engines and aggregates.
32
 *
33
 * @author Janos Szurovecz <[email protected]>
34
 */
35
abstract class AbstractDomainEvent extends AbstractMessage implements DomainEvent
36
{
37
    use StateHashTrait;
38
39
    protected $aggregateClass;
40
    protected $aggregateValue;
41
42
    /**
43
     * @param AbstractDomainEvent $event
44
     * @param AggregateId $aggregateId
45
     * @param $stateHash
46
     * @return AbstractDomainEvent
47
     */
48
    public static function initEvent(AbstractDomainEvent $event, AggregateId $aggregateId, $stateHash)
49
    {
50
        $event->setAggregateId($aggregateId);
51
        $event->stateHash = $stateHash;
52
        return $event;
53
    }
54
55
    /**
56
     * @param AggregateId|null $aggregateId
57
     */
58
    public function __construct(AggregateId $aggregateId = null)
59
    {
60
        parent::__construct();
61
        if ($aggregateId === null) {
62
            $aggregateId = NullAggregateId::instance();
63
        }
64
        $this->setAggregateId($aggregateId);
65
    }
66
67
    /**
68
     * @return GenericAggregateId
69
     */
70
    public function aggregateId()
71
    {
72
        return new GenericAggregateId($this->aggregateValue, $this->aggregateClass);
73
    }
74
75
    protected function toStringHelper()
76
    {
77
        return parent::toStringHelper()
78
            ->add($this->aggregateId())
79
            ->add('stateHash', $this->stateHash());
80
    }
81
82
    /**
83
     * @param AggregateId $aggregateId
84
     */
85
    private function setAggregateId(AggregateId $aggregateId)
86
    {
87
        $this->aggregateClass = $aggregateId->aggregateClass();
88
        $this->aggregateValue = $aggregateId->value();
89
    }
90
}
91