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 (#59)
by joseph
19:28
created

UniqueStringFieldTrait::metaForUniqueString()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 7
rs 10
c 0
b 0
f 0
ccs 6
cts 6
cp 1
cc 1
nc 1
nop 1
crap 1
1
<?php declare(strict_types=1);
2
3
namespace EdmondsCommerce\DoctrineStaticMeta\Entity\Fields\Traits\String;
4
5
// phpcs:disable
6
7
use Doctrine\ORM\Mapping\Builder\ClassMetadataBuilder;
8
use EdmondsCommerce\DoctrineStaticMeta\Entity\Fields\Interfaces\String\UniqueStringFieldInterface;
9
use EdmondsCommerce\DoctrineStaticMeta\Entity\Interfaces\ValidatedEntityInterface;
10
use EdmondsCommerce\DoctrineStaticMeta\MappingHelper;
11
use Symfony\Component\Validator\Mapping\ClassMetadata as ValidatorClassMetaData;
12
13
// phpcs:enable
14
trait UniqueStringFieldTrait
15
{
16
17
    /**
18
     * @var string|null
19
     */
20
    private $uniqueString;
21
22
    /**
23
     * @SuppressWarnings(PHPMD.StaticAccess)
24
     * @param ClassMetadataBuilder $builder
25
     */
26 1
    public static function metaForUniqueString(ClassMetadataBuilder $builder): void
27
    {
28 1
        MappingHelper::setSimpleStringFields(
29 1
            [UniqueStringFieldInterface::PROP_UNIQUE_STRING],
30 1
            $builder,
31 1
            UniqueStringFieldInterface::DEFAULT_UNIQUE_STRING,
32 1
            true
33
        );
34 1
    }
35
36
    /**
37
     * This method sets the validation for this field.
38
     *
39
     * You should add in as many relevant property constraints as you see fit.
40
     *
41
     * Remove the PHPMD suppressed warning once you start setting constraints
42
     *
43
     * @SuppressWarnings(PHPMD.UnusedFormalParameter)
44
     * @see https://symfony.com/doc/current/validation.html#supported-constraints
45
     *
46
     * @param ValidatorClassMetaData $metadata
47
     *
48
     * @throws \Symfony\Component\Validator\Exception\MissingOptionsException
49
     * @throws \Symfony\Component\Validator\Exception\InvalidOptionsException
50
     * @throws \Symfony\Component\Validator\Exception\ConstraintDefinitionException
51
     */
52 2
    protected static function validatorMetaForUniqueString(ValidatorClassMetaData $metadata)
0 ignored issues
show
Unused Code introduced by
The parameter $metadata is not used and could be removed. ( Ignorable by Annotation )

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

52
    protected static function validatorMetaForUniqueString(/** @scrutinizer ignore-unused */ ValidatorClassMetaData $metadata)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
53
    {
54
        //        $metadata->addPropertyConstraint(
55
        //            UniqueStringFieldInterface::PROP_UNIQUE_STRING,
56
        //            new NotBlank()
57
        //        );
58 2
    }
59
60
    /**
61
     * @return string|null
62
     */
63 2
    public function getUniqueString(): ?string
64
    {
65 2
        if (null === $this->uniqueString) {
66 1
            return UniqueStringFieldInterface::DEFAULT_UNIQUE_STRING;
67
        }
68
69 2
        return $this->uniqueString;
70
    }
71
72
    /**
73
     * @param string|null $uniqueString
74
     *
75
     * @return self
76
     */
77 2
    public function setUniqueString(?string $uniqueString): self
78
    {
79 2
        $this->uniqueString = $uniqueString;
80 2
        if ($this instanceof ValidatedEntityInterface) {
81 2
            $this->validateProperty(UniqueStringFieldInterface::PROP_UNIQUE_STRING);
82
        }
83
84 2
        return $this;
85
    }
86
}
87