StartTime   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 4

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 3
c 2
b 0
f 0
lcom 0
cbo 4
dl 0
loc 33
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getKpi() 0 9 2
A getFormat() 0 4 1
1
<?php
2
/**
3
 * Start time
4
 *
5
 * @package CacheCheck\Service\Analyzer
6
 * @author  Tim Lochmüller
7
 */
8
9
namespace HDNET\CacheCheck\Service\Analyzer;
10
11
use HDNET\CacheCheck\Domain\Model\Cache;
12
use HDNET\CacheCheck\Exception;
13
14
/**
15
 * Start time
16
 *
17
 * @author Tim Lochmüller
18
 */
19
class StartTime extends AbstractAnalyzer
20
{
21
22
    /**
23
     * Get the given KPI
24
     *
25
     * @param Cache $cache
26
     *
27
     * @return mixed
28
     * @throws \HDNET\CacheCheck\Exception
29
     */
30
    public function getKpi(Cache $cache)
31
    {
32
        $startTime = $this->getDatabaseConnection()
33
            ->exec_SELECTgetSingleRow('timestamp', 'tx_cachecheck_domain_model_log', 'cache_name = "' . $cache->getName() . '"', '', 'timestamp ASC');
34
        if (!isset($startTime['timestamp'])) {
35
            throw new Exception('No start time found', 1236723844);
36
        }
37
        return (int)($startTime['timestamp'] / 1000);
38
    }
39
40
    /**
41
     * Format the given KPI
42
     *
43
     * @param mixed $kpi
44
     *
45
     * @return string
46
     */
47
    public function getFormat($kpi)
48
    {
49
        return date('d.m.Y H:i:s', $kpi);
50
    }
51
}
52