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 (#51)
by joseph
102:38 queued 99:24
created

NameFieldTrait::getName()   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

Importance

Changes 0
Metric Value
dl 0
loc 3
c 0
b 0
f 0
ccs 2
cts 2
cp 1
rs 10
cc 1
eloc 1
nc 1
nop 0
crap 1
1
<?php declare(strict_types=1);
2
3
4
namespace EdmondsCommerce\DoctrineStaticMeta\Entity\Fields\Traits\Attribute;
5
6
use Doctrine\ORM\Mapping\Builder\ClassMetadataBuilder;
7
use EdmondsCommerce\DoctrineStaticMeta\Entity\Fields\Interfaces\Attribute\NameFieldInterface;
8
use EdmondsCommerce\DoctrineStaticMeta\Entity\Interfaces\EntityInterface;
9
use EdmondsCommerce\DoctrineStaticMeta\Entity\Interfaces\ValidatedEntityInterface;
10
use EdmondsCommerce\DoctrineStaticMeta\MappingHelper;
11
use Symfony\Component\Validator\Constraints\Length;
12
use Symfony\Component\Validator\Mapping\ClassMetadata as ValidatorClassMetaData;
13
14
trait NameFieldTrait
15
{
16
    /**
17
     * @var string
18
     */
19
    private $name;
20
21
    /**
22
     * @SuppressWarnings(PHPMD.StaticAccess)
23
     * @param ClassMetadataBuilder $builder
24
     */
25
    protected static function metaForName(ClassMetadataBuilder $builder): void
26
    {
27
        MappingHelper::setSimpleStringFields(
28
            [NameFieldInterface::PROP_NAME],
29
            $builder
30
        );
31
    }
32
33
    /**
34
     * @param ValidatorClassMetaData $metadata
35
     *
36
     * @throws \Symfony\Component\Validator\Exception\MissingOptionsException
37
     * @throws \Symfony\Component\Validator\Exception\InvalidOptionsException
38
     * @throws \Symfony\Component\Validator\Exception\ConstraintDefinitionException
39
     */
40
    protected static function validatorMetaForName(ValidatorClassMetaData $metadata): void
41
    {
42
        $metadata->addPropertyConstraint(
43
            NameFieldInterface::PROP_NAME,
44
            new Length(['min' => 2])
45
        );
46
    }
47
48
    /**
49
     * Get name
50
     *
51
     * @return string
52
     */
53 1
    public function getName(): ?string
54
    {
55 1
        return $this->name;
56
    }
57
58
    /**
59
     * Set name
60
     *
61
     * @param string $name
62
     *
63
     * @return $this
64
     */
65 1
    public function setName(?string $name): self
66
    {
67 1
        $this->name = $name;
68 1
        if ($this instanceof ValidatedEntityInterface) {
69 1
            $this->validateProperty(NameFieldInterface::PROP_NAME);
70
        }
71
72 1
        return $this;
73
    }
74
}
75