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 (#153)
by joseph
20:25
created

SkeletonEmbeddable::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 3
nc 1
nop 2
dl 0
loc 5
rs 10
c 0
b 0
f 0
1
<?php declare(strict_types=1);
2
3
namespace TemplateNamespace\Entity\Embeddable\Objects\CatName;
4
5
use Doctrine\ORM\Mapping\ClassMetadata;
6
use EdmondsCommerce\DoctrineStaticMeta\Entity\Embeddable\Objects\AbstractEmbeddableObject;
7
use EdmondsCommerce\DoctrineStaticMeta\MappingHelper;
8
use TemplateNamespace\Entity\Embeddable\Interfaces\CatName\HasSkeletonEmbeddableInterface;
9
use TemplateNamespace\Entity\Embeddable\Interfaces\Objects\CatName\SkeletonEmbeddableInterface;
10
11
class SkeletonEmbeddable extends AbstractEmbeddableObject implements SkeletonEmbeddableInterface
12
{
13
    /**
14
     * @var string
15
     */
16
    private $propertyOne;
17
    /**
18
     * @var string
19
     */
20
    private $propertyTwo;
21
22
    public function __construct(string $propertyOne, string $propertyTwo)
23
    {
24
        $this->validate($propertyOne, $propertyTwo);
25
        $this->propertyOne = $propertyOne;
26
        $this->propertyTwo = $propertyTwo;
27
    }
28
29
    private function validate(string $propertyOne, string $propertyTwo): void
30
    {
31
        $errors = [];
32
        if ('' === $propertyOne) {
33
            $errors[] = 'property one is empty';
34
        }
35
        if ('' === $propertyTwo) {
36
            $errors[] = 'property two is empty';
37
        }
38
        if ([] === $errors) {
39
            return;
40
        }
41
        throw new \InvalidArgumentException('Invalid arguments: ' . print_r($errors, true));
42
    }
43
44
    /**
45
     * @param ClassMetadata $metadata
46
     * @SuppressWarnings(PHPMD.StaticAccess)
47
     */
48
    public static function loadMetadata(ClassMetadata $metadata): void
49
    {
50
        $builder = self::setEmbeddableAndGetBuilder($metadata);
51
        MappingHelper::setSimpleFields(
52
            [
53
                SkeletonEmbeddableInterface::EMBEDDED_PROP_PROPERTY_ONE => MappingHelper::TYPE_STRING,
54
                SkeletonEmbeddableInterface::EMBEDDED_PROP_PROPERTY_TWO => MappingHelper::TYPE_STRING,
55
            ],
56
            $builder
57
        );
58
    }
59
60
    public function __toString(): string
61
    {
62
        return (string)print_r(
63
            [
64
                'skeletonEmbeddable' => [
65
                    SkeletonEmbeddableInterface::EMBEDDED_PROP_PROPERTY_ONE => $this->getPropertyOne(),
66
                    SkeletonEmbeddableInterface::EMBEDDED_PROP_PROPERTY_TWO => $this->getPropertyTwo(),
67
                ],
68
            ],
69
            true
70
        );
71
    }
72
73
    /**
74
     * @return string
75
     */
76
    public function getPropertyOne(): string
77
    {
78
        return $this->propertyOne;
79
    }
80
81
    /**
82
     * @return string
83
     */
84
    public function getPropertyTwo(): string
85
    {
86
        return $this->propertyTwo;
87
    }
88
89
    protected function getPrefix(): string
90
    {
91
        return HasSkeletonEmbeddableInterface::PROP_SKELETON_EMBEDDABLE;
92
    }
93
}