NewRelicClient   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A logDeployment() 0 8 1
1
<?php
2
3
namespace ParityBit\DeploymentNotifier\Clients;
4
5
use Curl\Curl;
6
7
class NewRelicClient
8
{
9
    protected $curl;
10
    protected $appName;
11
12
    const NOTIFICATION_URL = 'https://api.newrelic.com/deployments.xml';
13
14
    public function __construct(Curl $curl, $apiKey, $appName)
15
    {
16
        $this->curl = $curl;
17
        $this->curl->setHeader('x-api-key', $apiKey);
18
        $this->appName = $appName;
19
    }
20
21
    public function logDeployment()
22
    {
23
        // SHOULDDO: Use API v2
24
        $this->curl->post(
25
            self::NOTIFICATION_URL,
26
            'deployment[app_name]=' . $this->appName
0 ignored issues
show
Documentation introduced by
'deployment[app_name]=' . $this->appName is of type string, but the function expects a array.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
27
        );
28
    }
29
}
30