Owners::getById()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 1
dl 0
loc 6
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace SevenShores\Hubspot\Resources;
4
5
/**
6
 * Class Owners
7
 * @package SevenShores\Hubspot\Resources
8
 */
9
class Owners extends Resource
10
{
11
    /**
12
     * @param array $properties
13
     * @return \SevenShores\Hubspot\Http\Response
14
     */
15
    function create($properties)
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...
16
    {
17
        $endpoint = 'https://api.hubapi.com/owners/v2/owners/';
18
        $options['json'] = $properties;
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...
19
20
        return $this->client->request('post', $endpoint, $options);
21
    }
22
23
    /**
24
     * @param int $id
25
     * @param array $properties
26
     * @return \SevenShores\Hubspot\Http\Response
27
     */
28
    function update($id, $properties)
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...
29
    {
30
        $endpoint = "https://api.hubapi.com/owners/v2/owners/{$id}";
31
        $options['json'] = $properties;
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...
32
33
        return $this->client->request('put', $endpoint, $options);
34
    }
35
36
    /**
37
     * @param int $id
38
     * @return \SevenShores\Hubspot\Http\Response
39
     */
40
    function getById($id)
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...
41
    {
42
        $endpoint = 'https://api.hubapi.com/owners/v2/owners/'.$id;
43
44
        return $this->client->request('get', $endpoint);
45
    }
46
47
    /**
48
     * @param array $params
49
     * @return \SevenShores\Hubspot\Http\Response
50
     */
51
    function all($params = [])
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...
52
    {
53
        $endpoint = 'https://api.hubapi.com/owners/v2/owners';
54
55
        $queryString = build_query_string($params);
56
57
        return $this->client->request('get', $endpoint, [], $queryString);
58
    }
59
}
60