Uptime::read()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 13
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 1 Features 1
Metric Value
cc 2
eloc 10
nc 2
nop 1
dl 0
loc 13
rs 9.4285
c 2
b 1
f 1
1
<?php
2
3
namespace Uptime\Runtime\Windows;
4
5
use Uptime\Runtime\RuntimeInterface;
6
7
use DateTime;
8
9
class Uptime implements RuntimeInterface
10
{
11
12
    public function read(RuntimeInterface $boottime = null)
13
    {
14
        $boottime = $boottime ? $boottime  : new Boottime();
15
        $now = new DateTime('now');
16
        $interval = $now->diff( new DateTime( '@' . $boottime->read() ) );
17
18
        return ($interval->y * 365 * 24 * 60 * 60) +
19
               ($interval->m * 30 * 24 * 60 * 60) +
20
               ($interval->d * 24 * 60 * 60) +
21
               ($interval->h * 60 * 60) +
22
               ($interval->i * 60) +
23
               ($interval->s);
24
    }
25
}
26