Passed
Pull Request — master (#1716)
by Nico
23:15
created

UserSetting::setUser()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 3
nc 1
nop 1
dl 0
loc 6
ccs 0
cts 4
cp 0
crap 2
rs 10
c 1
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Stu\Orm\Entity;
6
7
use Doctrine\ORM\Mapping\Column;
8
use Doctrine\ORM\Mapping\Entity;
9
use Doctrine\ORM\Mapping\Id;
10
use Doctrine\ORM\Mapping\JoinColumn;
11
use Doctrine\ORM\Mapping\ManyToOne;
12
use Doctrine\ORM\Mapping\Table;
13
use Stu\Module\PlayerSetting\Lib\UserSettingEnum;
14
15
/**
16
 * @Entity(repositoryClass="Stu\Orm\Repository\UserSettingRepository")
17
 * @Table(
18
 *     name="stu_user_setting"
19
 * )
20
 **/
21
class UserSetting implements UserSettingInterface
22
{
23
    /**
24
     * @Id
25
     * @Column(type="integer")
26
     *
27
     */
28
    private int $user_id;
29
30
    /**
31
     * @Id
32
     * @Column(type="string", enumType=UserSettingEnum::class)
33
     *
34
     */
35
    private UserSettingEnum $setting;
36
37
    /**
38
     * @Column(type="string")
39
     *
40
     */
41
    private string $value = '';
42
43
    /**
44
     *
45
     * @ManyToOne(targetEntity="User")
46
     * @JoinColumn(name="user_id", referencedColumnName="id", onDelete="CASCADE")
47
     */
48
    private UserInterface $user;
49
50
    public function setUser(UserInterface $user): UserSettingInterface
51
    {
52
        $this->user = $user;
53
        $this->user_id = $user->getId();
54
55
        return $this;
56
    }
57
58
    public function setSetting(UserSettingEnum $setting): UserSettingInterface
59
    {
60
        $this->setting = $setting;
0 ignored issues
show
Documentation Bug introduced by
It seems like $setting of type Stu\Module\PlayerSetting\Lib\UserSettingEnum is incompatible with the declared type string of property $setting.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
61
62
        return $this;
63
    }
64
65
    public function getValue(): string
66
    {
67
        return $this->value;
68
    }
69
70
    public function setValue(string $value): UserSettingInterface
71
    {
72
        $this->value = $value;
73
74
        return $this;
75
    }
76
}
77