Completed
Push — master ( c5110b...a167e6 )
by Valentyn
13:46
created

ImdbCountry::getId()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 0
cts 2
cp 0
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace App\Countries\Entity;
6
7
use Doctrine\ORM\Mapping as ORM;
8
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
9
10
/**
11
 * @ORM\Entity(repositoryClass="App\Countries\Repository\ImdbCountryRepository")
12
 * @ORM\Table(name="imdb_countries")
13
 * @UniqueEntity(fields="name", message="This country already exists")
14
 */
15
class ImdbCountry
16
{
17
    /**
18
     * @ORM\Id()
19
     * @ORM\GeneratedValue()
20
     * @ORM\Column(type="integer")
21
     */
22
    private $id;
23
24
    /**
25
     * @ORM\OneToOne(targetEntity="App\Countries\Entity\Country")
26
     * @ORM\JoinColumn(nullable=false)
27
     */
28
    private $country;
29
30
    /**
31
     * @ORM\Column(type="string", length=50, unique=true)
32
     */
33
    private $name;
34
35
    /**
36
     * @ORM\Column(type="string", length=255)
37
     */
38
    private $altNames;
39
40
    public function __construct(Country $country, string $name = '', string $altNames = '')
41
    {
42
        $this->country = $country;
43
        $this->name = $name ?: $country->getName();
44
        $this->altNames = $altNames;
45
    }
46
47
    public function getId()
48
    {
49
        return $this->id;
50
    }
51
52
    public function getCountry(): Country
53
    {
54
        return $this->country;
55
    }
56
57
    public function getName(): string
58
    {
59
        return $this->name;
60
    }
61
62
    public function getAltNames(): string
63
    {
64
        return $this->altNames;
65
    }
66
}
67