Dossier::setSummary()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Yiisoft\ActiveRecord\Tests\Stubs\ActiveRecord;
6
7
use Yiisoft\ActiveRecord\ActiveQuery;
8
use Yiisoft\ActiveRecord\ActiveQueryInterface;
9
use Yiisoft\ActiveRecord\Tests\Stubs\ActiveRecord;
10
11
/**
12
 * Class Dossier
13
 */
14
final class Dossier extends ActiveRecord
15
{
16
    protected int $id;
17
    protected int $department_id;
18
    protected int $employee_id;
19
    protected string $summary;
20
21
    public function getTableName(): string
22
    {
23
        return 'dossier';
24
    }
25
26
    public function getId(): int
27
    {
28
        return $this->id;
29
    }
30
31
    public function getDepartmentId(): int
32
    {
33
        return $this->department_id;
34
    }
35
36
    public function getEmployeeId(): int
37
    {
38
        return $this->employee_id;
39
    }
40
41
    public function getSummary(): string
42
    {
43
        return $this->summary;
44
    }
45
46
    public function setId(int $id): void
47
    {
48
        $this->id = $id;
49
    }
50
51
    public function setDepartmentId(int $departmentId): void
52
    {
53
        $this->setAttribute('department_id', $departmentId);
54
    }
55
56
    public function setEmployeeId(int $employeeId): void
57
    {
58
        $this->setAttribute('employee_id', $employeeId);
59
    }
60
61
    public function setSummary(string $summary): void
62
    {
63
        $this->summary = $summary;
64
    }
65
66
    public function relationQuery(string $name): ActiveQueryInterface
67
    {
68
        return match ($name) {
69
            'employee' => $this->getEmployeeQuery(),
70
            default => parent::relationQuery($name),
71
        };
72
    }
73
74
    public function getEmployee(): Employee|null
75
    {
76
        return $this->relation('employee');
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->relation('employee') could return the type array which is incompatible with the type-hinted return Yiisoft\ActiveRecord\Tes...iveRecord\Employee|null. Consider adding an additional type-check to rule them out.
Loading history...
77
    }
78
79
    public function getEmployeeQuery(): ActiveQuery
80
    {
81
        return $this->hasOne(
82
            Employee::class,
83
            [
84
                'department_id' => 'department_id',
85
                'id' => 'employee_id',
86
            ]
87
        )->inverseOf('dossier');
88
    }
89
}
90