Passed
Pull Request — master (#198)
by Wilmer
02:47
created

DummyActiveRecord::insert()   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
cc 1
eloc 1
nc 1
nop 1
dl 0
loc 3
rs 10
c 1
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Yiisoft\ActiveRecord\Tests\Stubs;
6
7
use Yiisoft\ActiveRecord\BaseActiveRecord;
8
use Yiisoft\Db\Exception\NotSupportedException;
9
10
/**
11
 * ActiveRecord is the base class for classes representing relational data in terms of objects.
12
 *
13
 * This class implements the ActiveRecord pattern for the [redis](http://redis.io/) key-value store.
14
 *
15
 * For defining a record a subclass should at least implement the {@see attributes()} method to define attributes. A
16
 * primary key can be defined via {@see primaryKey()} which defaults to `id` if not specified.
17
 *
18
 * The following is an example model called `Customer`:
19
 *
20
 * ```php
21
 * class Customer extends \Yiisoft\Db\Redis\ActiveRecord
22
 * {
23
 *     public function attributes()
24
 *     {
25
 *         return ['id', 'name', 'address', 'registration_date'];
26
 *     }
27
 * }
28
 * ```
29
 */
30
class DummyActiveRecord extends BaseActiveRecord
31
{
32
    public static function tableName(): string
33
    {
34
        return 'dummy';
35
    }
36
37
    public function primaryKey(): array
38
    {
39
        throw new NotSupportedException(__METHOD__ . ' is not supported.');
40
    }
41
42
    public function attributes(): array
43
    {
44
        throw new NotSupportedException(__METHOD__ . ' is not supported.');
45
    }
46
47
    public function insert(?array $attributes = null): bool
48
    {
49
        throw new NotSupportedException(__METHOD__ . ' is not supported.');
50
    }
51
}
52