Passed
Pull Request — master (#361)
by Alexander
02:53
created

Item::getPromotions()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 1
c 1
b 0
f 0
dl 0
loc 3
rs 10
cc 1
nc 1
nop 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Yiisoft\ActiveRecord\Tests\Driver\Pgsql\Stubs;
6
7
use Yiisoft\ActiveRecord\ActiveQueryInterface;
8
9
/**
10
 * Class Item.
11
 */
12
final class Item extends \Yiisoft\ActiveRecord\Tests\Stubs\ActiveRecord\Item
13
{
14
    public function relationQuery(string $name): ActiveQueryInterface
15
    {
16
        return match ($name) {
17
            'promotions' => $this->hasMany(Promotion::class, ['item_ids' => 'id']),
18
            default => parent::relationQuery($name),
19
        };
20
    }
21
22
    /** @return Promotion[] */
23
    public function getPromotions(): array
24
    {
25
        return $this->relation('promotions');
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->relation('promotions') could return the type Yiisoft\ActiveRecord\ActiveRecordInterface|null which is incompatible with the type-hinted return array. Consider adding an additional type-check to rule them out.
Loading history...
26
    }
27
}
28