Passed
Pull Request — master (#273)
by
unknown
02:35
created

CustomerForArrayable::toArray()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

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