HasPerSecond   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 5

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getKpi() 0 10 2
A getFormat() 0 4 1
1
<?php
2
/**
3
 * Has 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
 * Has per second
16
 *
17
 * @author Tim Lochmüller
18
 */
19
class HasPerSecond 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 = "has"');
34
        $logTime = $this->getAnalyzer('LogTime');
35
        if ($logTime->getKpi($cache) == 0) {
36
            throw new Exception('No valid log time found', 123627467234);
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