Passed
Push — master ( 594551...748657 )
by Wilmer
02:40
created

CustomerClosureField::fields()   A

Complexity

Conditions 2
Paths 1

Size

Total Lines 9
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 4
c 1
b 0
f 0
dl 0
loc 9
rs 10
cc 2
nc 1
nop 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Yiisoft\ActiveRecord\Tests\Stubs\ActiveRecord;
6
7
use Yiisoft\ActiveRecord\ActiveRecord;
8
9
/**
10
 * Class CustomerClosureField.
11
 *
12
 * @property int $id
13
 * @property string $name
14
 * @property string $email
15
 * @property string $address
16
 * @property int $status
17
 */
18
final class CustomerClosureField extends ActiveRecord
19
{
20
    public function getTableName(): string
21
    {
22
        return 'customer';
23
    }
24
25
    public function fields(): array
26
    {
27
        $fields = parent::fields();
28
29
        $fields['status'] = static function (self $customer) {
30
            return $customer->status === 1 ? 'active' : 'inactive';
31
        };
32
33
        return $fields;
34
    }
35
}
36