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 DealProperties extends Resource |
||
| 6 | { |
||
| 7 | |||
| 8 | /** |
||
| 9 | * Get a Deal Property. |
||
| 10 | * |
||
| 11 | * Returns a JSON object representing the definition for a given deal property. |
||
| 12 | * |
||
| 13 | * @see http://developers.hubspot.com/docs/methods/deals/get_deal_property |
||
| 14 | * |
||
| 15 | * @param string $name The name of the property. |
||
| 16 | * @return \SevenShores\Hubspot\Http\Response |
||
| 17 | */ |
||
| 18 | function get($name) |
||
|
0 ignored issues
–
show
|
|||
| 19 | { |
||
| 20 | $endpoint = "https://api.hubapi.com/deals/v1/properties/named/{$name}"; |
||
| 21 | |||
| 22 | return $this->client->request('get', $endpoint); |
||
| 23 | } |
||
| 24 | |||
| 25 | /** |
||
| 26 | * Create a deal property. |
||
| 27 | * |
||
| 28 | * Create a property on every deal object to store a specific piece of data. In the example below, |
||
| 29 | * we want to store an invoice number on a separate field on deals. |
||
| 30 | * |
||
| 31 | * @see https://developers.hubspot.com/docs/methods/deals/create_deal_property |
||
| 32 | * |
||
| 33 | * @param array $property |
||
| 34 | * @return \SevenShores\Hubspot\Http\Response |
||
| 35 | */ |
||
| 36 | function create($property) |
||
|
0 ignored issues
–
show
|
|||
| 37 | { |
||
| 38 | $endpoint = "https://api.hubapi.com/properties/v1/deals/properties/"; |
||
| 39 | |||
| 40 | $options['json'] = $property; |
||
|
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...
|
|||
| 41 | |||
| 42 | return $this->client->request('post', $endpoint, $options); |
||
| 43 | } |
||
| 44 | |||
| 45 | /** |
||
| 46 | * Update a deal property. |
||
| 47 | * |
||
| 48 | * Update a specified deal property. |
||
| 49 | * |
||
| 50 | * @see http://developers.hubspot.com/docs/methods/deals/update_deal_property |
||
| 51 | * |
||
| 52 | * @param string $name |
||
| 53 | * @param array $property |
||
| 54 | * @return \SevenShores\Hubspot\Http\Response |
||
| 55 | */ |
||
| 56 | function update($name, $property) |
||
|
0 ignored issues
–
show
|
|||
| 57 | { |
||
| 58 | $endpoint = "https://api.hubapi.com/deals/v1/properties/named/{$name}"; |
||
| 59 | |||
| 60 | $property['name'] = $name; |
||
| 61 | $options['json'] = $property; |
||
|
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...
|
|||
| 62 | |||
| 63 | return $this->client->request('put', $endpoint, $options); |
||
| 64 | } |
||
| 65 | |||
| 66 | /** |
||
| 67 | * Delete a deal property. |
||
| 68 | * |
||
| 69 | * @see https://developers.hubspot.com/docs/methods/deals/delete_deal_property |
||
| 70 | * |
||
| 71 | * @param string $name |
||
| 72 | * @return \Psr\Http\Message\ResponseInterface|\SevenShores\Hubspot\Http\Response |
||
| 73 | */ |
||
| 74 | public function delete($name) |
||
| 75 | { |
||
| 76 | $endpoint = 'https://api.hubapi.com/properties/v1/deals/properties/named/' . $name; |
||
| 77 | return $this->client->request('delete', $endpoint); |
||
| 78 | } |
||
| 79 | |||
| 80 | /** |
||
| 81 | * Returns all of deal properties |
||
| 82 | * |
||
| 83 | * @see https://developers.hubspot.com/docs/methods/deals/get_deal_properties |
||
| 84 | * |
||
| 85 | * @return \Psr\Http\Message\ResponseInterface|\SevenShores\Hubspot\Http\Response |
||
| 86 | */ |
||
| 87 | public function all() |
||
| 88 | { |
||
| 89 | $endpoint = 'https://api.hubapi.com/properties/v1/deals/properties/'; |
||
| 90 | return $this->client->request('get', $endpoint); |
||
| 91 | } |
||
| 92 | |||
| 93 | /** |
||
| 94 | * Create a new deal property group to gather like deal-level data. |
||
| 95 | * @param array $group Defines the group and any properties within it. |
||
| 96 | * |
||
| 97 | * @see https://developers.hubspot.com/docs/methods/deals/create_deal_property_group |
||
| 98 | * |
||
| 99 | * @return \Psr\Http\Message\ResponseInterface|\SevenShores\Hubspot\Http\Response |
||
| 100 | */ |
||
| 101 | public function createGroup($group) |
||
| 102 | { |
||
| 103 | $endpoint = 'https://api.hubapi.com/properties/v1/deals/groups/'; |
||
| 104 | $options['json'] = $group; |
||
| 105 | return $this->client->request('post', $endpoint, $options); |
||
| 106 | } |
||
| 107 | |||
| 108 | /** |
||
| 109 | * Update a previously created deal property group. |
||
| 110 | * @param string $groupName The API name of the property group that you will be updating. |
||
| 111 | * @param array $group Defines the property group and any properties within it. |
||
| 112 | * |
||
| 113 | * @see https://developers.hubspot.com/docs/methods/deals/update_deal_property_group |
||
| 114 | * |
||
| 115 | * @return \SevenShores\Hubspot\Http\Response |
||
| 116 | */ |
||
| 117 | function updateGroup($groupName, $group) |
||
|
0 ignored issues
–
show
|
|||
| 118 | { |
||
| 119 | $endpoint = "https://api.hubapi.com/properties/v1/deals/groups/named/{$groupName}"; |
||
| 120 | |||
| 121 | $group['name'] = $groupName; |
||
| 122 | $options['json'] = $group; |
||
|
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...
|
|||
| 123 | |||
| 124 | return $this->client->request('put', $endpoint, $options); |
||
| 125 | } |
||
| 126 | |||
| 127 | /** |
||
| 128 | * Delete an existing deal property group. |
||
| 129 | * @param string $groupName The API name of the property group that you will be deleting. |
||
| 130 | * |
||
| 131 | * @see https://developers.hubspot.com/docs/methods/deals/delete_deal_property_group |
||
| 132 | * |
||
| 133 | * @return \SevenShores\Hubspot\Http\Response |
||
| 134 | */ |
||
| 135 | function deleteGroup($groupName) |
||
|
0 ignored issues
–
show
|
|||
| 136 | { |
||
| 137 | $endpoint = "https://api.hubapi.com/properties/v1/deals/groups/named/{$groupName}"; |
||
| 138 | |||
| 139 | return $this->client->request('delete', $endpoint); |
||
| 140 | } |
||
| 141 | |||
| 142 | /** |
||
| 143 | * Get a deals property group by name |
||
| 144 | * |
||
| 145 | * @param string $groupName The API name of the property group that you will be returned. |
||
| 146 | * @param bool $includeProperties If true returns all of the properties for each deal property group. |
||
| 147 | * |
||
| 148 | * @see https://developers.hubspot.com/docs/methods/deals/get_deal_property_group |
||
| 149 | * |
||
| 150 | * @return \Psr\Http\Message\ResponseInterface|\SevenShores\Hubspot\Http\Response |
||
| 151 | */ |
||
| 152 | View Code Duplication | public function getGroup($groupName, $includeProperties = false) |
|
| 153 | { |
||
| 154 | $endpoint = "https://api.hubapi.com/properties/v1/deals/groups/named/{$groupName}"; |
||
| 155 | |||
| 156 | if($includeProperties){ |
||
| 157 | $queryString = build_query_string(['includeProperties' => 'true']); |
||
| 158 | |||
| 159 | return $this->client->request('get', $endpoint, [], $queryString); |
||
| 160 | } |
||
| 161 | |||
| 162 | return $this->client->request('get', $endpoint); |
||
| 163 | } |
||
| 164 | |||
| 165 | /** |
||
| 166 | * Returns all of the deal property groups for a given portal. |
||
| 167 | * @param bool $includeProperties If true returns all of the properties for each deal property group. |
||
| 168 | * |
||
| 169 | * @see https://developers.hubspot.com/docs/methods/deals/get_deal_property_groups |
||
| 170 | * |
||
| 171 | * @return \SevenShores\Hubspot\Http\Response |
||
| 172 | */ |
||
| 173 | View Code Duplication | function getAllGroups($includeProperties = false) |
|
|
0 ignored issues
–
show
|
|||
| 174 | { |
||
| 175 | $endpoint = 'https://api.hubapi.com/properties/v1/deals/groups'; |
||
| 176 | |||
| 177 | if($includeProperties){ |
||
| 178 | $queryString = build_query_string(['includeProperties' => 'true']); |
||
| 179 | |||
| 180 | return $this->client->request('get', $endpoint, [], $queryString); |
||
| 181 | } |
||
| 182 | |||
| 183 | return $this->client->request('get', $endpoint); |
||
| 184 | } |
||
| 185 | } |
||
| 186 |
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.