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

CustomerForArrayable   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 14
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 3
eloc 5
c 1
b 0
f 1
dl 0
loc 14
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getTableName() 0 3 1
A toArray() 0 7 2
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
}