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

Location   A

Complexity

Total Complexity 9

Size/Duplication

Total Lines 55
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 9
eloc 18
c 0
b 0
f 0
dl 0
loc 55
rs 10

9 Methods

Rating   Name   Duplication   Size   Complexity  
A getPostalCode() 0 3 1
A getCity() 0 3 1
A getId() 0 3 1
A getCountry() 0 3 1
A getStreet() 0 3 1
A getName() 0 3 1
A getIdentity() 0 3 1
A getCoords() 0 3 1
A getAttributeMap() 0 10 1
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\GeoPoint;
16
use Daikon\ValueObject\IntValue;
17
use Daikon\ValueObject\Text;
18
use Daikon\ValueObject\ValueObjectInterface;
19
20
final class Location implements EntityInterface
21
{
22
    use EntityTrait;
23
24
    public static function getAttributeMap(): AttributeMap
25
    {
26
        return new AttributeMap([
27
            Attribute::define('id', IntValue::class),
28
            Attribute::define('name', Text::class),
29
            Attribute::define('street', Text::class),
30
            Attribute::define('postalCode', Text::class),
31
            Attribute::define('city', Text::class),
32
            Attribute::define('country', Text::class),
33
            Attribute::define('coords', GeoPoint::class)
34
        ]);
35
    }
36
37
    public function getIdentity(): ValueObjectInterface
38
    {
39
        return $this->getId();
40
    }
41
42
    public function getId(): IntValue
43
    {
44
        return $this->get('id') ?? IntValue::zero();
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->get('id') ...Object\IntValue::zero() could return the type Daikon\ValueObject\ValueObjectInterface which includes types incompatible with the type-hinted return Daikon\ValueObject\IntValue. Consider adding an additional type-check to rule them out.
Loading history...
45
    }
46
47
    public function getName(): ?Text
48
    {
49
        return $this->get('name');
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->get('name') returns the type Daikon\ValueObject\ValueObjectInterface which includes types incompatible with the type-hinted return Daikon\ValueObject\Text|null.
Loading history...
50
    }
51
52
    public function getStreet(): ?Text
53
    {
54
        return $this->get('street');
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->get('street') returns the type Daikon\ValueObject\ValueObjectInterface which includes types incompatible with the type-hinted return Daikon\ValueObject\Text|null.
Loading history...
55
    }
56
57
    public function getPostalCode(): ?Text
58
    {
59
        return $this->get('postalCode');
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->get('postalCode') returns the type Daikon\ValueObject\ValueObjectInterface which includes types incompatible with the type-hinted return Daikon\ValueObject\Text|null.
Loading history...
60
    }
61
62
    public function getCity(): ?Text
63
    {
64
        return $this->get('city');
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->get('city') returns the type Daikon\ValueObject\ValueObjectInterface which includes types incompatible with the type-hinted return Daikon\ValueObject\Text|null.
Loading history...
65
    }
66
67
    public function getCountry(): ?Text
68
    {
69
        return $this->get('country');
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->get('country') returns the type Daikon\ValueObject\ValueObjectInterface which includes types incompatible with the type-hinted return Daikon\ValueObject\Text|null.
Loading history...
70
    }
71
72
    public function getCoords(): ?GeoPoint
73
    {
74
        return $this->get('coords');
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->get('coords') returns the type Daikon\ValueObject\ValueObjectInterface which includes types incompatible with the type-hinted return Daikon\ValueObject\GeoPoint|null.
Loading history...
75
    }
76
}
77