Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
33.33% covered (danger)
33.33%
2 / 6
40.00% covered (danger)
40.00%
2 / 5
CRAP
0.00% covered (danger)
0.00%
0 / 1
CollectionItemOwned
33.33% covered (danger)
33.33%
2 / 6
40.00% covered (danger)
40.00%
2 / 5
16.67
0.00% covered (danger)
0.00%
0 / 1
 __construct
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 setOwned
0.00% covered (danger)
0.00%
0 / 2
0.00% covered (danger)
0.00%
0 / 1
6
 isOwned
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getId
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getCreatedBy
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
1<?php
2namespace Apie\Fixtures\Entities;
3
4use Apie\Core\Attributes\Context;
5use Apie\Core\Attributes\RuntimeCheck;
6use Apie\Core\Entities\EntityInterface;
7use Apie\Fixtures\Context\IsActivatedUser;
8use Apie\Fixtures\Identifiers\CollectionItemOwnedIdentifier;
9use Apie\Fixtures\Identifiers\UserWithAddressIdentifier;
10
11class CollectionItemOwned implements EntityInterface
12{
13    private UserWithAddressIdentifier $createdBy;
14
15    public function __construct(
16        private CollectionItemOwnedIdentifier $id,
17        #[Context('authenticated')]
18        UserWithAddress $createdBy,
19        private bool $owned
20    ) {
21        $this->createdBy = $createdBy->getId();
22    }
23
24    public function setOwned(
25        #[Context('authenticated')]
26        UserWithAddress $user,
27        bool $owned
28    ): void {
29        if ($user->getId()->toNative() === $this->createdBy->toNative()) {
30            $this->owned = $owned;
31        }
32    }
33
34    public function isOwned(): bool
35    {
36        return $this->owned;
37    }
38
39    public function getId(): CollectionItemOwnedIdentifier
40    {
41        return $this->id;
42    }
43
44    #[RuntimeCheck(new IsActivatedUser())]
45    public function getCreatedBy(): UserWithAddressIdentifier
46    {
47        return $this->createdBy;
48    }
49}