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 (#138)
by joseph
96:08 queued 65:06
created

UrlFieldTrait::setUrl()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 1

Importance

Changes 0
Metric Value
eloc 4
dl 0
loc 8
rs 10
c 0
b 0
f 0
ccs 5
cts 5
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\UrlFieldInterface;
9
use EdmondsCommerce\DoctrineStaticMeta\MappingHelper;
10
use Symfony\Component\Validator\Constraints\Url;
11
use Symfony\Component\Validator\Mapping\ClassMetadata as ValidatorClassMetaData;
12
13
// phpcs:enable
14
trait UrlFieldTrait
15
{
16
17
    /**
18
     * @var string|null
19
     */
20
    private $url;
21
22
    /**
23
     * @SuppressWarnings(PHPMD.StaticAccess)
24
     * @param ClassMetadataBuilder $builder
25
     */
26 1
    public static function metaForUrl(ClassMetadataBuilder $builder): void
27
    {
28 1
        MappingHelper::setSimpleStringFields(
29 1
            [UrlFieldInterface::PROP_URL],
30 1
            $builder,
31 1
            UrlFieldInterface::DEFAULT_URL,
32 1
            false
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
     * @param ValidatorClassMetaData $metadata
42
     *
43
     * @throws \Symfony\Component\Validator\Exception\MissingOptionsException
44
     * @throws \Symfony\Component\Validator\Exception\InvalidOptionsException
45
     * @throws \Symfony\Component\Validator\Exception\ConstraintDefinitionException
46
     */
47
    protected static function validatorMetaForUrl(ValidatorClassMetaData $metadata): void
48
    {
49
        $metadata->addPropertyConstraint(
50
            UrlFieldInterface::PROP_URL,
51
            new Url()
52
        );
53
    }
54
55
    /**
56
     * @return string|null
57
     */
58 2
    public function getUrl(): ?string
59
    {
60 2
        if (null === $this->url) {
61 1
            return UrlFieldInterface::DEFAULT_URL;
62
        }
63
64 2
        return $this->url;
65
    }
66
67
    /**
68
     * @param string|null $url
69
     *
70
     * @return self
71
     */
72 2
    public function setUrl(?string $url): self
73
    {
74 2
        $this->updatePropertyValueThenValidateAndNotify(
0 ignored issues
show
Bug introduced by
It seems like updatePropertyValueThenValidateAndNotify() 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

74
        $this->/** @scrutinizer ignore-call */ 
75
               updatePropertyValueThenValidateAndNotify(
Loading history...
75 2
            UrlFieldInterface::PROP_URL,
76 2
            $url
77
        );
78
79 2
        return $this;
80
    }
81
}
82