Issues (19)

tests/Fixture/Article.php (9 issues)

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\Entity;
14
use Daikon\ValueObject\BoolValue;
15
use Daikon\ValueObject\Date;
16
use Daikon\ValueObject\Email;
17
use Daikon\ValueObject\FloatValue;
18
use Daikon\ValueObject\Text;
19
use Daikon\ValueObject\Timestamp;
20
use Daikon\ValueObject\Url;
21
use Daikon\ValueObject\Uuid;
22
use Daikon\ValueObject\ValueObjectInterface;
23
24
final class Article extends Entity
25
{
26
    public static function getAttributeMap(): AttributeMap
27
    {
28
        return new AttributeMap([
29
            Attribute::define('id', Uuid::class),
30
            Attribute::define('created', Timestamp::class),
31
            Attribute::define('title', Text::class),
32
            Attribute::define('url', Url::class),
33
            Attribute::define('feedbackMail', Email::class),
34
            Attribute::define('averageVoting', FloatValue::class),
35
            Attribute::define('workshopDate', Date::class),
36
            Attribute::define('workshopCancelled', BoolValue::class),
37
            Attribute::define('workshopLocation', Location::class),
38
            Attribute::define('paragraphs', ParagraphList::class)
39
        ]);
40
    }
41
42
    public function getIdentity(): ValueObjectInterface
43
    {
44
        return $this->getId();
45
    }
46
47
    public function getId(): Uuid
48
    {
49
        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...
50
    }
51
52
    public function getTitle(): Text
53
    {
54
        return $this->get('title') ?? Text::makeEmpty();
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->get('title...bject\Text::makeEmpty() could return the type Daikon\ValueObject\ValueObjectInterface which includes types incompatible with the type-hinted return Daikon\ValueObject\Text. Consider adding an additional type-check to rule them out.
Loading history...
55
    }
56
57
    public function getUrl(): ?Url
58
    {
59
        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...
60
    }
61
62
    public function getFeedbackMail(): ?Email
63
    {
64
        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...
65
    }
66
67
    public function getAverageVoting(): ?FloatValue
68
    {
69
        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...
70
    }
71
72
    public function getWorkshopDate(): Date
73
    {
74
        return $this->get('workshopDate') ?? Date::makeEmpty();
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->get('works...bject\Date::makeEmpty() could return the type Daikon\ValueObject\ValueObjectInterface which includes types incompatible with the type-hinted return Daikon\ValueObject\Date. Consider adding an additional type-check to rule them out.
Loading history...
75
    }
76
77
    public function getWorkshopLocation(): ?Location
78
    {
79
        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...
80
    }
81
82
    public function isWorkshopCancelled(): BoolValue
83
    {
84
        return $this->get('workshopCancelled') ?? BoolValue::false();
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->get('works...ject\BoolValue::false() could return the type Daikon\ValueObject\ValueObjectInterface which includes types incompatible with the type-hinted return Daikon\ValueObject\BoolValue. Consider adding an additional type-check to rule them out.
Loading history...
85
    }
86
87
    public function getParagraphs(): ParagraphList
88
    {
89
        return $this->get('paragraphs') ?? ParagraphList::makeEmpty();
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->get('parag...agraphList::makeEmpty() could return the type Daikon\ValueObject\ValueObjectInterface which includes types incompatible with the type-hinted return Daikon\Tests\Entity\Fixture\ParagraphList. Consider adding an additional type-check to rule them out.
Loading history...
90
    }
91
}
92