Uptime   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 1
Bugs 0 Features 1
Metric Value
dl 0
loc 25
rs 10
c 1
b 0
f 1
wmc 3
lcom 0
cbo 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 9 1
A __toString() 0 4 1
A getRaw() 0 4 1
1
<?php
2
3
namespace Uptime;
4
5
use DateInterval;
6
7
class Uptime extends DateInterval
8
{
9
    protected $seconds;
10
11
    public function __construct($time)
12
    {
13
        $this->seconds = (float) $time;
14
        list($days, $time)    = [(int) ($time / 86400), $time % 86400];
15
        list($hours, $time)   = [(int) ($time / 3600), $time % 3600];
16
        list($minutes, $time) = [(int) ($time / 60), $time % 60];
17
        $seconds = $time;
18
        parent::__construct("P{$days}DT{$hours}H{$minutes}M{$seconds}S");
19
    }
20
21
    public function __toString()
22
    {
23
        return (string) $this->seconds;
24
    }
25
26
    public function getRaw()
27
    {
28
        return $this->seconds;
29
    }
30
31
}
32