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.
Passed
Pull Request — master (#39)
by joseph
04:31
created

NameFieldTrait::getPropertyDoctrineMetaForName()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 5
c 0
b 0
f 0
rs 9.4285
cc 1
eloc 4
nc 1
nop 1
1
<?php declare(strict_types=1);
2
3
namespace My\Test\Project\Entity\Fields\Traits;
4
// phpcs:disable
5
6
use \Doctrine\ORM\Mapping\Builder\ClassMetadataBuilder;
7
use \EdmondsCommerce\DoctrineStaticMeta\MappingHelper;
8
use EdmondsCommerce\DoctrineStaticMeta\Entity\Interfaces\EntityInterface;
9
use EdmondsCommerce\DoctrineStaticMeta\Entity\Interfaces\ValidatedEntityInterface;
10
use My\Test\Project\Entity\Fields\Interfaces\NameFieldInterface;
11
use Symfony\Component\Validator\Constraints\NotBlank;
12
use Symfony\Component\Validator\Mapping\ClassMetadata as ValidatorClassMetaData;
13
14
// phpcs:enable
15
trait NameFieldTrait {
16
17
	/**
18
	 * @var string|null
19
	 */
20
	private $name;
21
22
	/**
23
	 * @SuppressWarnings(PHPMD.StaticAccess) 
24
	 */
25
	public static function getPropertyDoctrineMetaForName(ClassMetadataBuilder $builder) {
26
		MappingHelper::setSimpleStringFields(
27
		            [NameFieldInterface::PROP_NAME],
28
		            $builder,
29
		            true
30
		        );
31
	}
32
33
	/**
34
	 * This method sets the validation for this field.
35
	 *
36
	 * You should add in as many relevant property constraints as you see fit.
37
	 * 
38
	 * Remove the PHPMD suppressed warning once you start setting constraints
39
	 *
40
	 * @SuppressWarnings(PHPMD.UnusedFormalParameter)
41
	 * @param ValidatorClassMetaData $metadata
42
	 * @throws \Symfony\Component\Validator\Exception\MissingOptionsException
43
	 * @throws \Symfony\Component\Validator\Exception\InvalidOptionsException
44
	 * @throws \Symfony\Component\Validator\Exception\ConstraintDefinitionException
45
	 */
46
	protected static function getPropertyValidatorMetaForName(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

46
	protected static function getPropertyValidatorMetaForName(/** @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...
47
		//        $metadata->addPropertyConstraint(
48
		//            NameFieldInterface::PROP_NAME,
49
		//            new NotBlank()
50
		//        );
51
	}
52
53
	/**
54
	 * @return string|null
55
	 */
56
	public function getName(): ?string {
57
		return $this->name;
58
	}
59
60
	/**
61
	 * @param string|null $name
62
	 * @return self
63
	 */
64
	public function setName(?string $name): self {
65
		$this->name = $name;
66
		if ($this instanceof ValidatedEntityInterface) {
67
		    $this->validateProperty(NameFieldInterface::PROP_NAME);
68
		}
69
		return $this;
70
	}
71
}
72