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 Forms extends Resource |
||
| 6 | { |
||
| 7 | /** |
||
| 8 | * Submit data to a form. |
||
| 9 | * |
||
| 10 | * @see http://developers.hubspot.com/docs/methods/forms/submit_form |
||
| 11 | * |
||
| 12 | * Send form submission data to HubSpot. Form submissions from external sources can be made to any registered |
||
| 13 | * HubSpot form. You can see a list of forms on your portal by going to the Contacts > Forms page |
||
| 14 | * |
||
| 15 | * @param int $portal_id |
||
| 16 | * @param string $form_guid |
||
| 17 | * @param array $form |
||
| 18 | * @return \SevenShores\Hubspot\Http\Response |
||
| 19 | */ |
||
| 20 | View Code Duplication | function submit($portal_id, $form_guid, $form) |
|
|
0 ignored issues
–
show
|
|||
| 21 | { |
||
| 22 | $endpoint = "https://forms.hubspot.com/uploads/form/v2/{$portal_id}/{$form_guid}"; |
||
| 23 | |||
| 24 | $options['form_params'] = $form; |
||
|
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...
|
|||
| 25 | |||
| 26 | return $this->client->request('post', $endpoint, $options, null, false); |
||
| 27 | } |
||
| 28 | |||
| 29 | /** |
||
| 30 | * Return all forms that have been created in the portal. |
||
| 31 | * |
||
| 32 | * @see http://developers.hubspot.com/docs/methods/forms/v2/get_forms |
||
| 33 | * |
||
| 34 | * @return \SevenShores\Hubspot\Http\Response |
||
| 35 | */ |
||
| 36 | function all() |
||
|
0 ignored issues
–
show
|
|||
| 37 | { |
||
| 38 | $endpoint = "https://api.hubapi.com/forms/v2/forms"; |
||
| 39 | |||
| 40 | return $this->client->request('get', $endpoint); |
||
| 41 | } |
||
| 42 | |||
| 43 | /** |
||
| 44 | * Return a single form based on the unique ID of that form. |
||
| 45 | * |
||
| 46 | * @see http://developers.hubspot.com/docs/methods/forms/v2/get_form |
||
| 47 | * |
||
| 48 | * @param string $form_guid |
||
| 49 | * @return \SevenShores\Hubspot\Http\Response |
||
| 50 | */ |
||
| 51 | function getById($form_guid) |
||
|
0 ignored issues
–
show
|
|||
| 52 | { |
||
| 53 | $endpoint = "https://api.hubapi.com/forms/v2/forms/{$form_guid}"; |
||
| 54 | |||
| 55 | return $this->client->request('get', $endpoint); |
||
| 56 | } |
||
| 57 | |||
| 58 | /** |
||
| 59 | * Create a new form. |
||
| 60 | * |
||
| 61 | * @see http://developers.hubspot.com/docs/methods/forms/v2/create_form |
||
| 62 | * |
||
| 63 | * @param array $form |
||
| 64 | * @return \SevenShores\Hubspot\Http\Response |
||
| 65 | */ |
||
| 66 | function create($form) |
||
|
0 ignored issues
–
show
|
|||
| 67 | { |
||
| 68 | $endpoint = "https://api.hubapi.com/forms/v2/forms"; |
||
| 69 | |||
| 70 | $options['json'] = $form; |
||
|
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...
|
|||
| 71 | |||
| 72 | return $this->client->request('post', $endpoint, $options); |
||
| 73 | } |
||
| 74 | |||
| 75 | /** |
||
| 76 | * Update an existing form. |
||
| 77 | * |
||
| 78 | * @see http://developers.hubspot.com/docs/methods/forms/v2/update_form |
||
| 79 | * |
||
| 80 | * @param string $form_guid |
||
| 81 | * @param array $form |
||
| 82 | * @return \SevenShores\Hubspot\Http\Response |
||
| 83 | */ |
||
| 84 | View Code Duplication | function update($form_guid, $form) |
|
|
0 ignored issues
–
show
|
|||
| 85 | { |
||
| 86 | $endpoint = "https://api.hubapi.com/forms/v2/forms/{$form_guid}"; |
||
| 87 | |||
| 88 | $options['json'] = $form; |
||
|
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...
|
|||
| 89 | |||
| 90 | return $this->client->request('post', $endpoint, $options); |
||
| 91 | } |
||
| 92 | |||
| 93 | /** |
||
| 94 | * Delete an existing form. |
||
| 95 | * |
||
| 96 | * @see http://developers.hubspot.com/docs/methods/forms/v2/delete_form |
||
| 97 | * |
||
| 98 | * @param string $form_guid |
||
| 99 | * @return \SevenShores\Hubspot\Http\Response |
||
| 100 | */ |
||
| 101 | function delete($form_guid) |
||
|
0 ignored issues
–
show
|
|||
| 102 | { |
||
| 103 | $endpoint = "https://api.hubapi.com/forms/v2/forms/{$form_guid}"; |
||
| 104 | |||
| 105 | return $this->client->request('delete', $endpoint); |
||
| 106 | } |
||
| 107 | |||
| 108 | /** |
||
| 109 | * Get all fields from a form. |
||
| 110 | * |
||
| 111 | * @see http://developers.hubspot.com/docs/methods/forms/v2/get_fields |
||
| 112 | * |
||
| 113 | * @param string $form_guid |
||
| 114 | * @return \SevenShores\Hubspot\Http\Response |
||
| 115 | */ |
||
| 116 | function getFields($form_guid) |
||
|
0 ignored issues
–
show
|
|||
| 117 | { |
||
| 118 | $endpoint = "https://api.hubapi.com/forms/v2/fields/{$form_guid}"; |
||
| 119 | |||
| 120 | return $this->client->request('get', $endpoint); |
||
| 121 | } |
||
| 122 | |||
| 123 | /** |
||
| 124 | * Get a single field from a form. |
||
| 125 | * |
||
| 126 | * @see http://developers.hubspot.com/docs/methods/forms/v2/get_field |
||
| 127 | * |
||
| 128 | * @param string $form_guid |
||
| 129 | * @param string $name |
||
| 130 | * @return \SevenShores\Hubspot\Http\Response |
||
| 131 | */ |
||
| 132 | function getFieldByName($form_guid, $name) |
||
|
0 ignored issues
–
show
|
|||
| 133 | { |
||
| 134 | $endpoint = "https://api.hubapi.com/forms/v2/fields/{$form_guid}/{$name}"; |
||
| 135 | |||
| 136 | return $this->client->request('get', $endpoint); |
||
| 137 | } |
||
| 138 | |||
| 139 | /** |
||
| 140 | * Get all submissions from a form. |
||
| 141 | * |
||
| 142 | * @see https://developers.hubspot.com/docs/methods/forms/get-submissions-for-a-form |
||
| 143 | * |
||
| 144 | * @param string $form_guid |
||
| 145 | * @return \SevenShores\Hubspot\Http\Response |
||
| 146 | */ |
||
| 147 | function getSubmissions($form_guid, $params = []){ |
||
|
0 ignored issues
–
show
|
|||
| 148 | $endpoint = "https://api.hubapi.com/form-integrations/v1/submissions/forms/{$form_guid}"; |
||
| 149 | |||
| 150 | $queryString = build_query_string($params); |
||
| 151 | |||
| 152 | return $this->client->request('get', $endpoint, [], $queryString); |
||
| 153 | } |
||
| 154 | |||
| 155 | } |
||
| 156 |
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.