SingleEmail::send()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 13

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 4
dl 0
loc 13
rs 9.8333
c 0
b 0
f 0
1
<?php
2
3
namespace SevenShores\Hubspot\Resources;
4
5
class SingleEmail extends Resource
6
{
7
    /**
8
     * Send an email designed and maintained in the HubSpot marketing Email Tool.
9
     *
10
     * @see http://developers.hubspot.com/docs/methods/email/transactional_email/single-send-overview
11
     *
12
     * @param int    $id
13
     * @param array  $message
14
     * @param array  $contactProperties
15
     * @param array  $customProperties
16
     * @return \SevenShores\Hubspot\Http\Response
17
     */
18
    function send($id, $message = [], $contactProperties = [], $customProperties = [])
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
19
    {
20
        $endpoint = "https://api.hubapi.com/email/public/v1/singleEmail/send";
21
22
        $options['json'] = [
0 ignored issues
show
Coding Style Comprehensibility introduced by
$options was never initialized. Although not strictly required by PHP, it is generally a good practice to add $options = array(); before regardless.

Adding an explicit array definition is generally preferable to implicit array definition as it guarantees a stable state of the code.

Let’s take a look at an example:

foreach ($collection as $item) {
    $myArray['foo'] = $item->getFoo();

    if ($item->hasBar()) {
        $myArray['bar'] = $item->getBar();
    }

    // do something with $myArray
}

As you can see in this example, the array $myArray is initialized the first time when the foreach loop is entered. You can also see that the value of the bar key is only written conditionally; thus, its value might result from a previous iteration.

This might or might not be intended. To make your intention clear, your code more readible and to avoid accidental bugs, we recommend to add an explicit initialization $myArray = array() either outside or inside the foreach loop.

Loading history...
23
          'emailId'           => $id,
24
          'message'           => $message,
25
          'contactProperties' => $contactProperties,
26
          'customProperties'  => $customProperties
27
        ];
28
29
        return $this->client->request('post', $endpoint, $options);
30
    }
31
}
32