DateTimeCastTrait::toDateTime()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
c 0
b 0
f 0
nc 1
nop 0
dl 0
loc 3
rs 10
1
<?php
2
3
namespace Helix\DB\Fluent\DateTime;
4
5
use Helix\DB\Fluent\AbstractTrait;
6
use Helix\DB\Fluent\DateTime;
7
8
/**
9
 * Further manipulate the expression as a date-time.
10
 */
11
trait DateTimeCastTrait
12
{
13
14
    use AbstractTrait;
15
16
    /**
17
     * Interpret the expression as a datetime.
18
     *
19
     * > Warning: If the expression's value is in the local timezone
20
     * > you should chain this with {@link DateTime::toUTC()}
21
     *
22
     * SQLite:
23
     * - The expression's value must conform to one of any `time-value` formats.
24
     * - https://www.sqlite.org/lang_datefunc.html
25
     *
26
     * MySQL:
27
     * - The expression's value must conform to `YYYY-MM-DD` or `YYYY-MM-DD hh:mm:ss`
28
     *
29
     * @return DateTime
30
     */
31
    public function toDateTime()
32
    {
33
        return DateTime::factory($this->db, $this);
34
    }
35
}
36