SchedulerLog::__toString()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 1
c 0
b 0
f 0
nc 1
nop 0
dl 0
loc 3
ccs 0
cts 2
cp 0
crap 2
rs 10
1
<?php
2
/**
3
 * @copyright Copyright(c) 2016 Webtools Ltd
4
 * @link https://github.com/thamtech/yii2-scheduler
5
 * @license https://opensource.org/licenses/MIT
6
**/
7
8
namespace thamtech\scheduler\models;
9
10
use Yii;
11
12
/**
13
 * This is the model class for table "scheduler_log".
14
 */
15
class SchedulerLog extends \thamtech\scheduler\models\base\SchedulerLog
16
{
17
    public function __toString()
18
    {
19
        return Yii::$app->formatter->asDatetime($this->started_at);
20
    }
21
22
    public function getDuration()
23
    {
24
        $start = new \DateTime($this->started_at);
25
        $end = new \DateTime($this->ended_at);
26
        $diff = $start->diff($end);
27
28
        return $diff->format('%hh %im %Ss');
29
    }
30
31
}
32