Issues (318)

Security Analysis    no request data  

This project does not seem to handle request data directly as such no vulnerable execution paths were found.

  Cross-Site Scripting
Cross-Site Scripting enables an attacker to inject code into the response of a web-request that is viewed by other users. It can for example be used to bypass access controls, or even to take over other users' accounts.
  File Exposure
File Exposure allows an attacker to gain access to local files that he should not be able to access. These files can for example include database credentials, or other configuration files.
  File Manipulation
File Manipulation enables an attacker to write custom data to files. This potentially leads to injection of arbitrary code on the server.
  Object Injection
Object Injection enables an attacker to inject an object into PHP code, and can lead to arbitrary code execution, file exposure, or file manipulation attacks.
  Code Injection
Code Injection enables an attacker to execute arbitrary code on the server.
  Response Splitting
Response Splitting can be used to send arbitrary responses.
  File Inclusion
File Inclusion enables an attacker to inject custom files into PHP's file loading mechanism, either explicitly passed to include, or for example via PHP's auto-loading mechanism.
  Command Injection
Command Injection enables an attacker to inject a shell command that is execute with the privileges of the web-server. This can be used to expose sensitive data, or gain access of your server.
  SQL Injection
SQL Injection enables an attacker to execute arbitrary SQL code on your database server gaining access to user data, or manipulating user data.
  XPath Injection
XPath Injection enables an attacker to modify the parts of XML document that are read. If that XML document is for example used for authentication, this can lead to further vulnerabilities similar to SQL Injection.
  LDAP Injection
LDAP Injection enables an attacker to inject LDAP statements potentially granting permission to run unauthorized queries, or modify content inside the LDAP tree.
  Header Injection
  Other Vulnerability
This category comprises other attack vectors such as manipulating the PHP runtime, loading custom extensions, freezing the runtime, or similar.
  Regex Injection
Regex Injection enables an attacker to execute arbitrary code in your PHP process.
  XML Injection
XML Injection enables an attacker to read files on your local filesystem including configuration files, or can be abused to freeze your web-server process.
  Variable Injection
Variable Injection enables an attacker to overwrite program variables with custom data, and can lead to further vulnerabilities.
Unfortunately, the security analysis is currently not available for your project. If you are a non-commercial open-source project, please contact support to gain access.

src/Resources/Companies.php (16 issues)

Upgrade to new PHP Analysis Engine

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 Companies extends Resource
6
{
7
8
    /**
9
     * Create a company
10
     * @param array $properties Array of company properties.
11
     *
12
     * @see http://developers.hubspot.com/docs/methods/companies/create_company
13
     *
14
     * @return \SevenShores\Hubspot\Http\Response
15
     */
16
    function create($properties)
0 ignored issues
show
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...
17
    {
18
        $endpoint = 'https://api.hubapi.com/companies/v2/companies/';
19
        $options['json'] = ['properties' => $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...
20
21
        return $this->client->request('post', $endpoint, $options);
22
    }
23
24
    /**
25
     * Updates a company
26
     * @param int $id The company id.
27
     * @param array $properties The company properties to update.
28
     *
29
     * @see http://developers.hubspot.com/docs/methods/companies/update_company
30
     *
31
     * @return \SevenShores\Hubspot\Http\Response
32
     */
33
    function update($id, $properties)
0 ignored issues
show
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...
34
    {
35
        $endpoint = "https://api.hubapi.com/companies/v2/companies/{$id}";
36
        $options['json'] = ['properties' => $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...
37
38
        return $this->client->request('put', $endpoint, $options);
39
    }
40
41
    /**
42
     * @param array $companies The companies and properties.
43
     * @return \SevenShores\Hubspot\Http\Response
44
     */
45
    function updateBatch($companies)
0 ignored issues
show
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...
46
    {
47
        $endpoint = "https://api.hubapi.com/companies/v1/batch-async/update";
48
        $options['json'] = $companies;
49
50
        return $this->client->request('post', $endpoint, $options);
51
    }
52
53
    /**
54
     * Deletes a company
55
     * @param int $id The company id
56
     *
57
     * @see http://developers.hubspot.com/docs/methods/companies/delete_company
58
     *
59
     * @return \SevenShores\Hubspot\Http\Response
60
     */
61
    function delete($id)
0 ignored issues
show
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...
62
    {
63
        $endpoint = "https://api.hubapi.com/companies/v2/companies/{$id}";
64
65
        return $this->client->request('delete', $endpoint);
66
    }
67
68
    /**
69
     * Returns all companies
70
     * @param array $params Array of optional parameters ['limit', 'offset', 'properties']
71
     *
72
     * @see http://developers.hubspot.com/docs/methods/companies/get-all-companies
73
     *
74
     * @return \SevenShores\Hubspot\Http\Response
75
     */
76
    function all($params = [])
0 ignored issues
show
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...
77
    {
78
        $endpoint = 'https://api.hubapi.com/companies/v2/companies/paged';
79
80
        $queryString = build_query_string($params);
81
82
        return $this->client->request('get', $endpoint, [], $queryString);
83
    }
84
85
    /**
86
     * Returns the recently modified companies
87
     * @param array $params Array of optional parameters ['count', 'offset']
88
     *
89
     * @see http://developers.hubspot.com/docs/methods/companies/get_companies_modified
90
     *
91
     * @return \SevenShores\Hubspot\Http\Response
92
     */
93
    function getRecentlyModified($params = [])
0 ignored issues
show
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...
94
    {
95
        $endpoint = 'https://api.hubapi.com/companies/v2/companies/recent/modified';
96
97
        $queryString = build_query_string($params);
98
99
        return $this->client->request('get', $endpoint, [], $queryString);
100
    }
101
102
    /**
103
     * Returns the recently created companies
104
     * @param array $params Array of optional parameters ['count', 'offset']
105
     *
106
     * @see http://developers.hubspot.com/docs/methods/companies/get_companies_created
107
     *
108
     * @return \SevenShores\Hubspot\Http\Response
109
     */
110
    function getRecentlyCreated($params = [])
0 ignored issues
show
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...
111
    {
112
        $endpoint = 'https://api.hubapi.com/companies/v2/companies/recent/created';
113
114
        $queryString = build_query_string($params);
115
116
        return $this->client->request('get', $endpoint, [], $queryString);
117
    }
118
119
    /**
120
     * Returns an array of companies that have a matching domain
121
     * @deprecated use searchByDomain instead
122
     * @param string $domain The domain of the company eq. 'example.com'.
123
     *
124
     * @see http://developers.hubspot.com/docs/methods/companies/get_companies_by_domain
125
     *
126
     * @return \SevenShores\Hubspot\Http\Response
127
     */
128
    function getByDomain($domain)
0 ignored issues
show
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...
129
    {
130
        $endpoint = "https://api.hubapi.com/companies/v2/companies/domain/{$domain}";
131
132
        return $this->client->request('get', $endpoint);
133
    }
134
135
    /**
136
     * @param string $domain
137
     * @param array $properties
138
     * @param int $limit
139
     * @param int $offset
140
     *
141
     * @see https://developers.hubspot.com/docs/methods/companies/search_companies_by_domain
142
     *
143
     * @return \Psr\Http\Message\ResponseInterface|\SevenShores\Hubspot\Http\Response
144
     */
145
    public function searchByDomain($domain, $properties = [], $limit = 100, $offset = 0)
146
    {
147
        $endpoint = "https://api.hubapi.com/companies/v2/domains/{$domain}/companies";
148
        $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...
149
            'limit' => $limit,
150
            'offset' => [
151
                'isPrimary' => true,
152
                'companyId' => $offset
153
            ],
154
            'requestOptions' => [
155
                'properties' => $properties
156
            ]
157
        ];
158
        return $this->client->request('post', $endpoint, $options);
159
    }
160
161
    /**
162
     * Returns a company with id $id
163
     * @param int $id
164
     *
165
     * @see http://developers.hubspot.com/docs/methods/companies/get_company
166
     *
167
     * @return \SevenShores\Hubspot\Http\Response
168
     */
169
    function getById($id)
0 ignored issues
show
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...
170
    {
171
        $endpoint = "https://api.hubapi.com/companies/v2/companies/{$id}";
172
173
        return $this->client->request('get', $endpoint);
174
    }
175
176
    /**
177
     * Associates a given contact to a given company
178
     * If a contact is already associated to a different company, the contact will be added to the new company
179
     * @param int $contactId
180
     * @param int $companyId
181
     *
182
     * @see http://developers.hubspot.com/docs/methods/companies/add_contact_to_company
183
     *
184
     * @return \SevenShores\Hubspot\Http\Response
185
     */
186
    function addContact($contactId, $companyId)
0 ignored issues
show
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...
187
    {
188
        $endpoint = "https://api.hubapi.com/companies/v2/companies/{$companyId}/contacts/{$contactId}";
189
190
        return $this->client->request('put', $endpoint);
191
    }
192
193
    /**
194
     * Returns an array of the associated contacts for the given company
195
     * @param int $companyId The id of the company.
196
     * @param array $params Array of optional parameters ['count', 'vidOffset']
197
     *
198
     * @see http://developers.hubspot.com/docs/methods/companies/get_company_contacts
199
     *
200
     * @return \SevenShores\Hubspot\Http\Response
201
     */
202
    function getAssociatedContacts($companyId, $params = [])
0 ignored issues
show
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...
203
    {
204
        $endpoint = "https://api.hubapi.com/companies/v2/companies/{$companyId}/contacts";
205
206
        $queryString = build_query_string($params);
207
208
        return $this->client->request('get', $endpoint, [], $queryString);
209
    }
210
211
    /**
212
     * Returns all of the contact IDs who are associated with the given company
213
     * @param int $companyId The id of the company.
214
     * @param array $params Array of optional parameters ['count', 'vidOffset']
215
     *
216
     * @see http://developers.hubspot.com/docs/methods/companies/get_company_contacts_by_id
217
     *
218
     * @return \SevenShores\Hubspot\Http\Response
219
     */
220
    function getAssociatedContactIds($companyId, $params = [])
0 ignored issues
show
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...
221
    {
222
        $endpoint = "https://api.hubapi.com/companies/v2/companies/{$companyId}/vids";
223
224
        $queryString = build_query_string($params);
225
226
        return $this->client->request('get', $endpoint, [], $queryString);
227
    }
228
229
    /**
230
     * Removes a contact from a company
231
     * @param int $contactId
232
     * @param int $companyId
233
     *
234
     * @see http://developers.hubspot.com/docs/methods/companies/remove_contact_from_company
235
     *
236
     * @return \SevenShores\Hubspot\Http\Response
237
     */
238
    function removeContact($contactId, $companyId)
0 ignored issues
show
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...
239
    {
240
        $endpoint = "https://api.hubapi.com/companies/v2/companies/{$companyId}/contacts/{$contactId}";
241
242
        return $this->client->request('delete', $endpoint);
243
    }
244
245
246
247
}
248