Passed
Push — master ( d25e4d...dba989 )
by Mr
06:54
created

Article::getAttributeMap()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 13
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 11
c 0
b 0
f 0
dl 0
loc 13
rs 9.9
cc 1
nc 1
nop 0
1
<?php declare(strict_types=1);
2
/**
3
 * This file is part of the daikon-cqrs/entity project.
4
 *
5
 * For the full copyright and license information, please view the LICENSE
6
 * file that was distributed with this source code.
7
 */
8
9
namespace Daikon\Tests\Entity\Fixture;
10
11
use Daikon\Entity\Attribute;
12
use Daikon\Entity\AttributeMap;
13
use Daikon\Entity\EntityInterface;
14
use Daikon\Entity\EntityTrait;
15
use Daikon\ValueObject\BoolValue;
16
use Daikon\ValueObject\Date;
17
use Daikon\ValueObject\Email;
18
use Daikon\ValueObject\FloatValue;
19
use Daikon\ValueObject\Text;
20
use Daikon\ValueObject\Timestamp;
21
use Daikon\ValueObject\Url;
22
use Daikon\ValueObject\Uuid;
23
use Daikon\ValueObject\ValueObjectInterface;
24
25
final class Article implements EntityInterface
26
{
27
    use EntityTrait;
28
29
    public static function getAttributeMap(): AttributeMap
30
    {
31
        return new AttributeMap([
32
            Attribute::define('id', Uuid::class),
33
            Attribute::define('created', Timestamp::class),
34
            Attribute::define('title', Text::class),
35
            Attribute::define('url', Url::class),
36
            Attribute::define('feedbackMail', Email::class),
37
            Attribute::define('averageVoting', FloatValue::class),
38
            Attribute::define('workshopDate', Date::class),
39
            Attribute::define('workshopCancelled', BoolValue::class),
40
            Attribute::define('workshopLocation', Location::class),
41
            Attribute::define('paragraphs', ParagraphList::class)
42
        ]);
43
    }
44
45
    public function getIdentity(): ValueObjectInterface
46
    {
47
        return $this->getId();
48
    }
49
50
    public function getId(): Uuid
51
    {
52
        return $this->get('id') ?? Uuid::generate();
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->get('id') ...Object\Uuid::generate() could return the type Daikon\ValueObject\ValueObjectInterface which includes types incompatible with the type-hinted return Daikon\ValueObject\Uuid. Consider adding an additional type-check to rule them out.
Loading history...
53
    }
54
55
    public function getTitle(): ?Text
56
    {
57
        return $this->get('title');
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->get('title') returns the type Daikon\ValueObject\ValueObjectInterface which includes types incompatible with the type-hinted return Daikon\ValueObject\Text|null.
Loading history...
58
    }
59
60
    public function getUrl(): ?Url
61
    {
62
        return $this->get('url');
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->get('url') returns the type Daikon\ValueObject\ValueObjectInterface which includes types incompatible with the type-hinted return Daikon\ValueObject\Url|null.
Loading history...
63
    }
64
65
    public function getFeedbackMail(): ?Email
66
    {
67
        return $this->get('feedbackMail');
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->get('feedbackMail') returns the type Daikon\ValueObject\ValueObjectInterface which includes types incompatible with the type-hinted return Daikon\ValueObject\Email|null.
Loading history...
68
    }
69
70
    public function getAverageVoting(): ?FloatValue
71
    {
72
        return $this->get('averageVoting');
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->get('averageVoting') returns the type Daikon\ValueObject\ValueObjectInterface which includes types incompatible with the type-hinted return Daikon\ValueObject\FloatValue|null.
Loading history...
73
    }
74
75
    public function getWorkshopDate(): ?Date
76
    {
77
        return $this->get('workshopDate');
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->get('workshopDate') returns the type Daikon\ValueObject\ValueObjectInterface which includes types incompatible with the type-hinted return Daikon\ValueObject\Date|null.
Loading history...
78
    }
79
80
    public function getWorkshopLocation(): ?Location
81
    {
82
        return $this->get('workshopLocation');
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->get('workshopLocation') returns the type Daikon\ValueObject\ValueObjectInterface which includes types incompatible with the type-hinted return Daikon\Tests\Entity\Fixture\Location|null.
Loading history...
83
    }
84
85
    public function isWorkshopCancelled(): ?BoolValue
86
    {
87
        return $this->get('workshopCancelled') ?? BoolValue::fromNative(false);
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->get('works...alue::fromNative(false) could return the type Daikon\ValueObject\ValueObjectInterface which includes types incompatible with the type-hinted return Daikon\ValueObject\BoolValue|null. Consider adding an additional type-check to rule them out.
Loading history...
88
    }
89
90
    public function getParagraphs(): ?ParagraphList
91
    {
92
        return $this->get('paragraphs') ?? ParagraphList::makeEmpty();
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->get('parag...agraphList::makeEmpty() returns the type Daikon\ValueObject\Value...ct\ValueObjectInterface which is incompatible with the type-hinted return Daikon\Tests\Entity\Fixture\ParagraphList|null.
Loading history...
93
    }
94
}
95