Monitor   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 17
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 7
dl 0
loc 17
rs 10
c 0
b 0
f 0
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A starting() 0 7 1
1
<?php
2
/**
3
 * HTTP server stats reporting
4
 * User: moyo
5
 * Date: 2018/6/15
6
 * Time: 12:26 PM
7
 */
8
9
namespace Carno\Web\Components;
10
11
use Carno\Console\Component;
12
use Carno\Console\Contracts\Application;
13
use Carno\Console\Contracts\Bootable;
14
use Carno\Monitor\Metrics;
15
use Carno\Monitor\Ticker;
16
use Carno\Web\Controller\Stats;
17
18
class Monitor extends Component implements Bootable
19
{
20
    /**
21
     * @var array
22
     */
23
    protected $prerequisites = [Metrics::class];
24
25
    /**
26
     * @param Application $app
27
     */
28
    public function starting(Application $app) : void
29
    {
30
        $app->starting()->add(static function () {
31
            Ticker::new([
32
                Metrics::gauge()->named('web.ctrl.working'),
33
            ], static function (Metrics\Gauge $wc) {
34
                $wc->set(Stats::working());
35
            });
36
        });
37
    }
38
}
39