HasOptionalCountry::setCountry()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 2
eloc 1
c 1
b 0
f 1
nc 2
nop 1
dl 0
loc 3
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Del\Traits;
6
7
use Bone\BoneDoctrine\Attributes\Visibility;
0 ignored issues
show
Bug introduced by
The type Bone\BoneDoctrine\Attributes\Visibility 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...
8
use Del\Entity\Country;
9
use Del\Factory\CountryFactory;
10
use Del\Form\Field\Attributes\Field;
11
use Del\Form\Field\CountrySelect;
12
use Doctrine\ORM\Mapping as ORM;
0 ignored issues
show
Bug introduced by
The type Doctrine\ORM\Mapping 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...
13
14
trait HasOptionalCountry
15
{
16
    #[ORM\Column(type: 'string', length:3, nullable: true)]
17
    #[Field(rules: 'custom', fieldClass: CountrySelect::class)]
18
    #[Visibility('all')]
19
    private ?string $country  = null;
20
21
    public function getCountry(): ?Country
22
    {
23
        return $this->country ? CountryFactory::generate($this->country) : null;
24
    }
25
26
    public function setCountry(mixed $country): void
27
    {
28
        $this->country = $country instanceof Country ? $country->getIso() : null;
29
    }
30
}
31