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
Push — master ( 69b831...bd71a5 )
by joseph
20:49 queued 13s
created

HasWeightEmbeddableTrait::getWeightEmbeddable()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1.037

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
ccs 2
cts 3
cp 0.6667
crap 1.037
rs 10
c 0
b 0
f 0
1
<?php declare(strict_types=1);
2
3
namespace EdmondsCommerce\DoctrineStaticMeta\Entity\Embeddable\Traits\Attribute;
4
5
use Doctrine\ORM\Events;
6
use Doctrine\ORM\Mapping\Builder\ClassMetadataBuilder;
7
use EdmondsCommerce\DoctrineStaticMeta\Entity\Embeddable\Interfaces\Attribute\HasWeightEmbeddableInterface;
8
use EdmondsCommerce\DoctrineStaticMeta\Entity\Embeddable\Interfaces\Objects\Attribute\WeightEmbeddableInterface;
9
use EdmondsCommerce\DoctrineStaticMeta\Entity\Embeddable\Objects\Attribute\WeightEmbeddable;
10
11
trait HasWeightEmbeddableTrait
12
{
13
    /**
14
     * @var WeightEmbeddableInterface
15
     */
16
    private $weightEmbeddable;
17
18
    /**
19
     * @param ClassMetadataBuilder $builder
20
     */
21 1
    protected static function metaForWeightEmbeddable(ClassMetadataBuilder $builder): void
22
    {
23 1
        $builder->addLifecycleEvent(
24 1
            'postLoadSetOwningEntityOnWeightEmbeddable',
25 1
            Events::postLoad
26
        );
27 1
        $builder->createEmbedded(
28 1
            HasWeightEmbeddableInterface::PROP_WEIGHT_EMBEDDABLE,
29 1
            WeightEmbeddable::class
30
        )
31 1
                ->setColumnPrefix(
32 1
                    HasWeightEmbeddableInterface::COLUMN_PREFIX_WEIGHT
33
                )
34 1
                ->build();
35 1
    }
36
37
    /**
38
     * @return mixed
39
     */
40 1
    public function getWeightEmbeddable(): WeightEmbeddableInterface
41
    {
42 1
        return $this->weightEmbeddable;
43
    }
44
45
    public function postLoadSetOwningEntityOnWeightEmbeddable(): void
46
    {
47
        $this->weightEmbeddable->setOwningEntity($this);
0 ignored issues
show
Bug introduced by
$this of type EdmondsCommerce\Doctrine...asWeightEmbeddableTrait 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

47
        $this->weightEmbeddable->setOwningEntity(/** @scrutinizer ignore-type */ $this);
Loading history...
48
    }
49
50
    /**
51
     * Called at construction time
52
     * @SuppressWarnings(PHPMD.StaticAccess)
53
     */
54 1
    private function initWeightEmbeddable(): void
55
    {
56 1
        $this->setWeightEmbeddable(
57 1
            new WeightEmbeddable(
58 1
                WeightEmbeddableInterface::DEFAULT_UNIT,
59 1
                WeightEmbeddableInterface::DEFAULT_VALUE
60
            ),
61 1
            false
62
        );
63 1
    }
64
65
    /**
66
     * @param WeightEmbeddableInterface $weightEmbeddable
67
     *
68
     * @param bool                      $notify
69
     *
70
     * @return $this
71
     * @SuppressWarnings(PHPMD.BooleanArgumentFlag)
72
     */
73 1
    private function setWeightEmbeddable(WeightEmbeddableInterface $weightEmbeddable, bool $notify = true): self
74
    {
75 1
        $this->weightEmbeddable = $weightEmbeddable;
76 1
        $this->weightEmbeddable->setOwningEntity($this);
0 ignored issues
show
Bug introduced by
$this of type EdmondsCommerce\Doctrine...asWeightEmbeddableTrait 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

76
        $this->weightEmbeddable->setOwningEntity(/** @scrutinizer ignore-type */ $this);
Loading history...
77 1
        if (true === $notify) {
78 1
            $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

78
            $this->/** @scrutinizer ignore-call */ 
79
                   notifyEmbeddablePrefixedProperties(
Loading history...
79 1
                HasWeightEmbeddableInterface::PROP_WEIGHT_EMBEDDABLE
80
            );
81
        }
82
83 1
        return $this;
84
    }
85
}
86