Passed
Pull Request — master (#329)
by Sergei
02:48
created

Employee   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 12
dl 0
loc 31
rs 10
c 0
b 0
f 0
wmc 4

4 Methods

Rating   Name   Duplication   Size   Complexity  
A getFullName() 0 3 1
A getTableName() 0 3 1
A getDossierQuery() 0 9 1
A getDepartmentQuery() 0 7 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\ActiveRecord;
9
10
/**
11
 * Class Employee
12
 *
13
 * @property int $id
14
 * @property int $department_id
15
 * @property string $first_name
16
 * @property string $last_name
17
 * @property string $fullName
18
 * @property Department $department
19
 * @property Dossier $dossier
20
 */
21
final class Employee extends ActiveRecord
22
{
23
    public function getTableName(): string
24
    {
25
        return 'employee';
26
    }
27
28
    public function getFullName(): string
29
    {
30
        return $this->first_name . ' ' . $this->last_name;
31
    }
32
33
    public function getDepartmentQuery(): ActiveQuery
34
    {
35
        return $this
36
            ->hasOne(Department::class, [
37
                'id' => 'department_id',
38
            ])
39
            ->inverseOf('employees')
40
        ;
41
    }
42
43
    public function getDossierQuery(): ActiveQuery
44
    {
45
        return $this->hasOne(
46
            Dossier::class,
47
            [
48
                'department_id' => 'department_id',
49
                'employee_id' => 'id',
50
            ]
51
        )->inverseOf('employee');
52
    }
53
}
54