Completed
Push — master ( 3592ed...983069 )
by Guillaume
02:39
created

MetricPusher   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 4

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
c 1
b 0
f 0
lcom 0
cbo 4
dl 0
loc 21
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A push() 0 15 2
1
<?php
2
3
/*
4
 * This file is part of the hogosha-monitor package
5
 *
6
 * Copyright (c) 2016 Guillaume Cavana
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 *
11
 * Feel free to edit as you please, and have fun.
12
 *
13
 * @author Guillaume Cavana <[email protected]>
14
 */
15
16
namespace Hogosha\Monitor\Pusher;
17
18
use Hogosha\Monitor\Model\Result;
19
use Hogosha\Sdk\Resource\Factory\ResourceFactory;
20
21
/**
22
 * Class MetricPusher.
23
 */
24
class MetricPusher extends AbstractPusher
25
{
26
    /**
27
     * {@inheridoc}.
28
     */
29
    public function push(Result $result)
30
    {
31
        $resourceFactory = new ResourceFactory($this->getClient());
32
        $metricResource = $resourceFactory->get('metricPoint');
33
34
        try {
35
            $metricResource->createMetricPoint([
36
                'metric' => $result->getUrl()->getMetricUuid(),
37
                'value' => $result->getReponseTime() * 1000,
38
                'datetime' => date('Y-m-d H:i:s'),
39
            ]);
40
        } catch (\Exception $e) {
41
            echo sprintf('An error has occured %s', $e->getMessage());
42
        }
43
    }
44
}
45