SetPerSecond::getKpi()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 10
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
c 2
b 0
f 0
dl 0
loc 10
rs 9.4285
cc 2
eloc 7
nc 2
nop 1
1
<?php
2
/**
3
 * Set per second
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
 * Set per second
16
 *
17
 * @author Tim Lochmüller
18
 */
19
class SetPerSecond 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
        $countHas = $this->getDatabaseConnection()
33
            ->exec_SELECTcountRows('*', 'tx_cachecheck_domain_model_log', 'cache_name = "' . $cache->getName() . '"' . ' AND called_method = "set"');
34
        $logTime = $this->getAnalyzer('LogTime');
35
        if ($logTime->getKpi($cache) == 0) {
36
            throw new Exception('No valid log time found', 234738759234);
37
        }
38
        return $countHas / $logTime->getKpi($cache);
39
    }
40
41
    /**
42
     * Format the given KPI
43
     *
44
     * @param mixed $kpi
45
     *
46
     * @return string
47
     */
48
    public function getFormat($kpi)
49
    {
50
        return $kpi;
51
    }
52
}
53