Passed
Push — master ( 5834c4...c6f47c )
by y
01:38
created

DateTime::today()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 3
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 5
rs 10
1
<?php
2
3
namespace Helix\DB\Fluent;
4
5
use Helix\DB;
6
use Helix\DB\Fluent\DateTime\DateTimeTrait;
7
use Helix\DB\Fluent\Str\StrCastTrait;
8
9
/**
10
 * A date-time expression.
11
 */
12
class DateTime extends Expression implements ValueInterface
13
{
14
15
    use DateTimeTrait;
0 ignored issues
show
introduced by
The trait Helix\DB\Fluent\DateTime\DateTimeTrait requires some properties which are not provided by Helix\DB\Fluent\DateTime: $s, $y, $m, $i, $h, $d
Loading history...
16
    use FactoryFormatTrait;
17
    use StrCastTrait;
18
19
    /**
20
     * An expression for the current date and time.
21
     *
22
     * @param DB $db
23
     * @return static
24
     */
25
    public static function now(DB $db)
26
    {
27
        return static::fromFormat($db, [
28
            'mysql' => "NOW()",
29
            'sqlite' => "DATETIME()"
30
        ]);
31
    }
32
33
    /**
34
     * An expression for the current date.
35
     *
36
     * @param DB $db
37
     * @return static
38
     */
39
    public static function today(DB $db)
40
    {
41
        return static::fromFormat($db, [
42
            'mysql' => "CURDATE()",
43
            'sqlite' => "DATE()"
44
        ]);
45
    }
46
}
47