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
Pull Request — master (#152)
by joseph
17:58
created

HasMoneyEmbeddableTrait::initMoneyEmbeddable()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
ccs 0
cts 3
cp 0
crap 2
rs 10
c 0
b 0
f 0
1
<?php declare(strict_types=1);
2
3
namespace EdmondsCommerce\DoctrineStaticMeta\Entity\Embeddable\Traits\Financial;
4
5
use Doctrine\ORM\Events;
6
use Doctrine\ORM\Mapping\Builder\ClassMetadataBuilder;
7
use EdmondsCommerce\DoctrineStaticMeta\Entity\Embeddable\Interfaces\Financial\HasMoneyEmbeddableInterface;
8
use EdmondsCommerce\DoctrineStaticMeta\Entity\Embeddable\Interfaces\Objects\Financial\MoneyEmbeddableInterface;
9
use EdmondsCommerce\DoctrineStaticMeta\Entity\Embeddable\Objects\Financial\MoneyEmbeddable;
10
11
trait HasMoneyEmbeddableTrait
12
{
13
    /**
14
     * @var MoneyEmbeddableInterface
15
     */
16
    private $moneyEmbeddable;
17
18
    /**
19
     * @param ClassMetadataBuilder $builder
20
     */
21
    protected static function metaForMoney(ClassMetadataBuilder $builder): void
22
    {
23
        $builder->addLifecycleEvent(
24
            'postLoadSetOwningEntityOnMoneyEmbeddable',
25
            Events::postLoad
26
        );
27
        $builder->createEmbedded(
28
            HasMoneyEmbeddableInterface::PROP_MONEY_EMBEDDABLE,
29
            MoneyEmbeddable::class
30
        )
31
                ->setColumnPrefix(
32
                    HasMoneyEmbeddableInterface::COLUMN_PREFIX_MONEY
33
                )
34
                ->build();
35
    }
36
37
    public function postLoadSetOwningEntityOnMoneyEmbeddable(): void
38
    {
39
        $this->moneyEmbeddable->setOwningEntity($this);
0 ignored issues
show
Bug introduced by
$this of type EdmondsCommerce\Doctrine...HasMoneyEmbeddableTrait is incompatible with the type EdmondsCommerce\Doctrine...TrackingPolicyInterface expected by parameter $entity of EdmondsCommerce\Doctrine...face::setOwningEntity(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

39
        $this->moneyEmbeddable->setOwningEntity(/** @scrutinizer ignore-type */ $this);
Loading history...
40
    }
41
42
    /**
43
     * @return MoneyEmbeddableInterface
44
     */
45
    public function getMoneyEmbeddable(): MoneyEmbeddableInterface
46
    {
47
        return $this->moneyEmbeddable;
48
    }
49
50
    /**
51
     * Called at construction time
52
     */
53
    private function initMoneyEmbeddable(): void
54
    {
55
        $this->setMoneyEmbeddable(new MoneyEmbeddable(), false);
56
    }
57
58
    /**
59
     * @param MoneyEmbeddableInterface $moneyEmbeddable
60
     *
61
     * @param bool                     $notify
62
     *
63
     * @return $this
64
     * @SuppressWarnings(PHPMD.BooleanArgumentFlag)
65
     */
66
    private function setMoneyEmbeddable(
67
        MoneyEmbeddableInterface $moneyEmbeddable,
68
        bool $notify = true
69
    ): self {
70
        $this->moneyEmbeddable = $moneyEmbeddable;
71
        $this->moneyEmbeddable->setOwningEntity($this);
0 ignored issues
show
Bug introduced by
$this of type EdmondsCommerce\Doctrine...HasMoneyEmbeddableTrait is incompatible with the type EdmondsCommerce\Doctrine...TrackingPolicyInterface expected by parameter $entity of EdmondsCommerce\Doctrine...face::setOwningEntity(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

71
        $this->moneyEmbeddable->setOwningEntity(/** @scrutinizer ignore-type */ $this);
Loading history...
72
        if (true === $notify) {
73
            $this->notifyEmbeddablePrefixedProperties(
0 ignored issues
show
Bug introduced by
It seems like notifyEmbeddablePrefixedProperties() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

73
            $this->/** @scrutinizer ignore-call */ 
74
                   notifyEmbeddablePrefixedProperties(
Loading history...
74
                HasMoneyEmbeddableInterface::PROP_MONEY_EMBEDDABLE
75
            );
76
        }
77
78
        return $this;
79
    }
80
}
81