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 ( f20003...f7764e )
by Ross
17s queued 11s
created

JsonDataFieldTrait::initJsonData()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
ccs 0
cts 3
cp 0
crap 2
rs 10
c 0
b 0
f 0
1
<?php declare(strict_types=1);
2
3
namespace EdmondsCommerce\DoctrineStaticMeta\Entity\Fields\Traits\String;
4
5
// phpcs:disable Generic.Files.LineLength.TooLong
6
7
use Doctrine\ORM\Mapping\Builder\ClassMetadataBuilder;
8
use EdmondsCommerce\DoctrineStaticMeta\Entity\Fields\Interfaces\String\JsonDataFieldInterface;
9
use EdmondsCommerce\DoctrineStaticMeta\Entity\Validation\Constraints\DomainName;
0 ignored issues
show
Bug introduced by
The type EdmondsCommerce\Doctrine...\Constraints\DomainName was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
10
use EdmondsCommerce\DoctrineStaticMeta\Entity\Validation\Constraints\FieldConstraints\JsonData;
11
use EdmondsCommerce\DoctrineStaticMeta\MappingHelper;
12
use Symfony\Component\Validator\Mapping\ClassMetadata as ValidatorClassMetaData;
13
14
// phpcs:enable
15
trait JsonDataFieldTrait
16
{
17
18
    /**
19
     * @var string|null
20
     */
21
    private $jsonData;
22
23
    /**
24
     * @SuppressWarnings(PHPMD.StaticAccess)
25
     * @param ClassMetadataBuilder $builder
26
     */
27
    public static function metaForJsonData(ClassMetadataBuilder $builder): void
28
    {
29
        MappingHelper::setSimpleJsonFields(
30
            [JsonDataFieldInterface::PROP_JSON_DATA],
31
            $builder,
32
            JsonDataFieldInterface::DEFAULT_JSON_DATA,
33
            false
0 ignored issues
show
Unused Code introduced by
The call to EdmondsCommerce\Doctrine...::setSimpleJsonFields() has too many arguments starting with false. ( Ignorable by Annotation )

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

33
        MappingHelper::/** @scrutinizer ignore-call */ 
34
                       setSimpleJsonFields(

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.

Loading history...
34
        );
35
    }
36
37
    /**
38
     * Use a custom validator to call filter_var to validate that the domain name is valid
39
     *
40
     * @param ValidatorClassMetaData $metadata
41
     */
42
    protected static function validatorMetaForPropertyJsonData(ValidatorClassMetaData $metadata): void
43
    {
44
        $metadata->addPropertyConstraint(
45
            JsonDataFieldInterface::PROP_JSON_DATA,
46
            new JsonData()
47
        );
48
    }
49
50
    /**
51
     * @return string|null
52
     */
53
    public function getJsonData(): ?string
54
    {
55
        if (null === $this->jsonData) {
56
            return JsonDataFieldInterface::DEFAULT_JSON_DATA;
57
        }
58
59
        return $this->jsonData;
60
    }
61
62
    /**
63
     * @param string|null $json
64
     *
65
     * @return self
66
     */
67
    private function setJsonData(?string $json): self
68
    {
69
        $this->updatePropertyValue(
0 ignored issues
show
Bug introduced by
It seems like updatePropertyValue() 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

69
        $this->/** @scrutinizer ignore-call */ 
70
               updatePropertyValue(
Loading history...
70
            JsonDataFieldInterface::PROP_JSON_DATA,
71
            $json
72
        );
73
74
        return $this;
75
    }
76
77
    private function initJsonData()
78
    {
79
        $this->jsonData = JsonDataFieldInterface::DEFAULT_JSON_DATA;
80
    }
81
}
82