NewRelicClient::logDeployment()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 8
rs 9.4285
cc 1
eloc 4
nc 1
nop 0
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