Passed
Push — master ( fc6bbf...e39fda )
by Alexander
05:11
created

Migration::notNullTimestamp()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 8
ccs 0
cts 7
cp 0
rs 9.4285
cc 2
eloc 4
nc 2
nop 0
crap 6
1
<?php
2
3
namespace Horat1us\Yii;
4
5
use yii\db;
6
7
/**
8
 * Class Migration
9
 * @package Horat1us\Yii
10
 */
11
class Migration extends db\Migration
12
{
13
    public function notNullTimestamp(): db\ColumnSchemaBuilder
14
    {
15
        if ($this->db->driverName === 'mysql') {
16
            return $this->timestamp()->notNull()->defaultExpression('now()');
17
        }
18
19
        return $this->timestamp()->notNull();
20
    }
21
}
22