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

AbstractPusher   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 71
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

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

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A getDefaultFailedIncidentMessage() 0 4 1
A getDefaultResolvedIncidentMessage() 0 4 1
A getClient() 0 10 1
push() 0 1 ?
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\Api\Client;
20
21
/**
22
 * Class AbstractPusher.
23
 */
24
abstract class AbstractPusher implements PusherInterface
25
{
26
    /**
27
     * $client.
28
     *
29
     * @var Client
30
     */
31
    protected $client;
32
33
    /**
34
     * $options.
35
     *
36
     * @var array
37
     */
38
    protected $options;
39
40
    /**
41
     * Constructor.
42
     *
43
     * @param array $options
44
     */
45
    public function __construct(array $options)
46
    {
47
        $this->options = $options;
48
    }
49
50
    /**
51
     * getDefaultFailedIncidentMessage.
52
     *
53
     * @return string Default message used to create a incident when a failure as occured
54
     */
55
    public function getDefaultFailedIncidentMessage()
56
    {
57
        return $this->options['default_failed_incident_message'];
58
    }
59
60
    /**
61
     * getDefaultResolvedIncidentMessage.
62
     *
63
     * @return string Default message used to create a incident when a service is resolved as occured
64
     */
65
    public function getDefaultResolvedIncidentMessage()
66
    {
67
        return $this->options['default_resolved_incident_message'];
68
    }
69
70
    /**
71
     * getClient.
72
     *
73
     * @return Client
74
     */
75
    public function getClient()
76
    {
77
        return new Client(
78
            [
79
                'username' => $this->options['username'],
80
                'password' => $this->options['password'],
81
                'base_uri' => $this->options['base_uri'],
82
            ]
83
        );
84
    }
85
86
    /**
87
     * push.
88
     *
89
     * @param Result $result
90
     *
91
     * @return mixed
92
     */
93
    abstract public function push(Result $result);
94
}
95