Passed
Push — master ( 03282d...f5631a )
by Alexander
32:32 queued 17:38
created

PerformanceMetrics   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 15
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
eloc 6
c 1
b 0
f 0
dl 0
loc 15
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A run() 0 6 1
A __construct() 0 3 1
1
<?php
2
3
4
namespace App\Widget;
5
6
use App\Timer;
7
use Yiisoft\Widget\Widget;
8
9
class PerformanceMetrics extends Widget
10
{
11
    private Timer $timer;
12
13
    public function __construct(Timer $timer)
14
    {
15
        $this->timer = $timer;
16
    }
17
18
    protected function run(): string
19
    {
20
        $time = round($this->timer->get('overall'), 4);
21
        $memory = round(memory_get_peak_usage() / (1024 * 1024), 4);
22
23
        return "Time: $time s. Memory: $memory mb.";
24
    }
25
}
26