Beta   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 6
eloc 12
dl 0
loc 37
rs 10
c 0
b 0
f 0

6 Methods

Rating   Name   Duplication   Size   Complexity  
A getTableName() 0 3 1
A getAlphaStringIdentifier() 0 3 1
A getAlpha() 0 3 1
A getId() 0 3 1
A getAlphaQuery() 0 3 1
A relationQuery() 0 5 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
final class Beta extends ActiveRecord
12
{
13
    protected int $id;
14
    protected string $alpha_string_identifier;
15
    protected Alpha $alpha;
16
17
    public function getTableName(): string
18
    {
19
        return 'beta';
20
    }
21
22
    public function getId(): int
23
    {
24
        return $this->id;
25
    }
26
27
    public function getAlphaStringIdentifier(): string
28
    {
29
        return $this->alpha_string_identifier;
30
    }
31
32
    public function relationQuery(string $name): ActiveQueryInterface
33
    {
34
        return match ($name) {
35
            'alpha' => $this->getAlphaQuery(),
36
            default => parent::relationQuery($name),
37
        };
38
    }
39
40
    public function getAlpha(): Alpha|null
41
    {
42
        return $this->relation('alpha');
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->relation('alpha') could return the type array which is incompatible with the type-hinted return Yiisoft\ActiveRecord\Tes...ActiveRecord\Alpha|null. Consider adding an additional type-check to rule them out.
Loading history...
43
    }
44
45
    public function getAlphaQuery(): ActiveQuery
46
    {
47
        return $this->hasOne(Alpha::class, ['string_identifier' => 'alpha_string_identifier']);
48
    }
49
}
50