Completed
Push — master ( 074f1a...50e4ad )
by Jonathan
14:34
created

EncryptionStatsTrait::returnMiss()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 5
rs 9.4285
cc 1
eloc 3
nc 1
nop 1
1
<?php
2
namespace Jsq\Cache;
3
4
trait EncryptionStatsTrait
5
{
6
    private $hits = 0;
7
    private $misses = 0;
8
    private $encryptionTime = 0.0;
9
10
    private function getEncryptionStats(array $inner = [])
11
    {
12
        return [
13
            'hits' => $this->hits,
14
            'misses' => $this->misses,
15
            'encryption_time' => $this->encryptionTime,
16
        ] + $inner + [
17
            'uptime' => null,
18
            'memory_usage' => null,
19
            'memory_available' => null,
20
        ];
21
    }
22
23
    private function callAndTime(callable $func, array $args = [])
24
    {
25
        $start = microtime(true);
26
        $returnable = call_user_func_array($func, $args);
27
        $this->encryptionTime += microtime(true) - $start;
28
        return $returnable;
29
    }
30
31
    private function returnHit($hit)
32
    {
33
        $this->hits++;
34
        return $hit;
35
    }
36
37
    private function returnMiss($miss)
38
    {
39
        $this->misses++;
40
        return $miss;
41
    }
42
}
43