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

DummyActiveRecord   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 5
c 2
b 0
f 0
dl 0
loc 20
rs 10
wmc 4

4 Methods

Rating   Name   Duplication   Size   Complexity  
A tableName() 0 3 1
A primaryKey() 0 3 1
A attributes() 0 3 1
A insert() 0 3 1
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