ryanwinchester /
hubspot-php
This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include, or for example
via PHP's auto-loading mechanism.
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
| 1 | <?php |
||
| 2 | |||
| 3 | namespace SevenShores\Hubspot\Resources; |
||
| 4 | |||
| 5 | class BlogTopics extends Resource |
||
| 6 | { |
||
| 7 | |||
| 8 | /** |
||
| 9 | * Get all the blog topcis |
||
| 10 | * |
||
| 11 | * @param array $params Optional parameters ['name','slug','limit','offset'] |
||
| 12 | * @return \SevenShores\Hubspot\Http\Response |
||
| 13 | */ |
||
| 14 | function all($params = []) |
||
|
0 ignored issues
–
show
|
|||
| 15 | { |
||
| 16 | |||
| 17 | $endpoint = 'https://api.hubapi.com/blogs/v3/topics'; |
||
| 18 | |||
| 19 | $queryString = build_query_string($params); |
||
| 20 | |||
| 21 | return $this->client->request('get', $endpoint, [], $queryString); |
||
| 22 | } |
||
| 23 | |||
| 24 | /** |
||
| 25 | * Search a topic by the query. $query will match name and slug partially |
||
| 26 | * |
||
| 27 | * @see http://developers.hubspot.com/docs/methods/blog/v3/search-blog-topics |
||
| 28 | * |
||
| 29 | * @param string $query Search query |
||
| 30 | * @param array $params Array of optional parameters ['name','slug','limit', 'offset', 'active', 'blog'] |
||
| 31 | * @return \SevenShores\Hubspot\Http\Response |
||
| 32 | */ |
||
| 33 | function search($query, $params = []) |
||
|
0 ignored issues
–
show
|
|||
| 34 | { |
||
| 35 | $endpoint = 'https://api.hubapi.com/blogs/v3/topics/search'; |
||
| 36 | |||
| 37 | $params['q'] = $query; |
||
| 38 | |||
| 39 | $queryString = build_query_string($params); |
||
| 40 | |||
| 41 | return $this->client->request('get', $endpoint, [], $queryString); |
||
| 42 | } |
||
| 43 | |||
| 44 | /** |
||
| 45 | * @param int $id |
||
| 46 | * @return \SevenShores\Hubspot\Http\Response |
||
| 47 | */ |
||
| 48 | function getById($id) |
||
|
0 ignored issues
–
show
|
|||
| 49 | { |
||
| 50 | $endpoint = "https://api.hubapi.com/blogs/v3/topics/{$id}"; |
||
| 51 | |||
| 52 | return $this->client->request('get', $endpoint); |
||
| 53 | } |
||
| 54 | |||
| 55 | /** |
||
| 56 | * Create a new blog topic. |
||
| 57 | * |
||
| 58 | * @param string $name Name of the topic |
||
| 59 | * @param array $params Optional Parameters. |
||
| 60 | * @return \SevenShores\Hubspot\Http\Response |
||
| 61 | */ |
||
| 62 | View Code Duplication | function create($name, $params = []) |
|
|
0 ignored issues
–
show
|
|||
| 63 | { |
||
| 64 | $endpoint = 'https://api.hubapi.com/blogs/v3/topics'; |
||
| 65 | |||
| 66 | $params['name'] = $name; |
||
| 67 | |||
| 68 | $options['json'] = $params; |
||
|
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 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...
|
|||
| 69 | |||
| 70 | return $this->client->request('post', $endpoint, $options); |
||
| 71 | } |
||
| 72 | |||
| 73 | /** |
||
| 74 | * Update a blog topic. |
||
| 75 | * |
||
| 76 | * @param int $id The blog topic id. |
||
| 77 | * @param array $params The blog topic fields to update. |
||
| 78 | * @return \SevenShores\Hubspot\Http\Response |
||
| 79 | */ |
||
| 80 | function update($id, $params = []) |
||
|
0 ignored issues
–
show
|
|||
| 81 | { |
||
| 82 | $endpoint = "https://api.hubapi.com/blogs/v3/topics/{$id}"; |
||
| 83 | |||
| 84 | $options['json'] = $params; |
||
|
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 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...
|
|||
| 85 | |||
| 86 | return $this->client->request('put', $endpoint, $options); |
||
| 87 | } |
||
| 88 | |||
| 89 | /** |
||
| 90 | * Delete a blog topic. |
||
| 91 | * |
||
| 92 | * @param int $id |
||
| 93 | * @return \SevenShores\Hubspot\Http\Response |
||
| 94 | */ |
||
| 95 | function delete($id) |
||
|
0 ignored issues
–
show
|
|||
| 96 | { |
||
| 97 | $endpoint = "https://api.hubapi.com/blogs/v3/topics/{$id}"; |
||
| 98 | |||
| 99 | return $this->client->request('delete', $endpoint); |
||
| 100 | } |
||
| 101 | |||
| 102 | /** |
||
| 103 | * Group blog topics |
||
| 104 | * |
||
| 105 | * @param array $topicIds Array of topic ids |
||
| 106 | * @param string $groupedTopicName New name of the group |
||
| 107 | * @return \SevenShores\Hubspot\Http\Response |
||
| 108 | */ |
||
| 109 | function merge($topicIds, $groupedTopicName) |
||
|
0 ignored issues
–
show
|
|||
| 110 | { |
||
| 111 | $endpoint = "https://api.hubapi.com/blogs/v3/topics/group-topics"; |
||
| 112 | |||
| 113 | $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 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...
|
|||
| 114 | 'topicIds' => $topicIds, |
||
| 115 | 'groupedTopicName' => $groupedTopicName |
||
| 116 | ]; |
||
| 117 | |||
| 118 | return $this->client->request('post', $endpoint, $options); |
||
| 119 | } |
||
| 120 | } |
||
| 121 |
Adding explicit visibility (
private,protected, orpublic) is generally recommend to communicate to other developers how, and from where this method is intended to be used.