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 Sausin\Signere; |
||
4 | |||
5 | use UnexpectedValueException; |
||
6 | |||
7 | class DocumentProvider extends BaseClass |
||
8 | { |
||
9 | /** The URI of the action */ |
||
10 | const URI = 'https://api.signere.no/api/DocumentProvider'; |
||
11 | |||
12 | /** |
||
13 | * Retrieves a document provider account. |
||
14 | * |
||
15 | * @param string $providerId |
||
16 | * @return object |
||
17 | */ |
||
18 | 1 | public function getProviderAccount(string $providerId) |
|
19 | { |
||
20 | // make the URL for this request |
||
21 | 1 | $url = sprintf('%s/%s', $this->getBaseUrl(), $providerId); |
|
22 | |||
23 | // get the headers for this request |
||
24 | 1 | $headers = $this->headers->make('GET', $url); |
|
25 | |||
26 | // get the response |
||
27 | 1 | $response = $this->client->get($url, [ |
|
28 | 1 | 'headers' => $headers, |
|
29 | ]); |
||
30 | |||
31 | // return the response |
||
32 | 1 | return $response; |
|
33 | } |
||
34 | |||
35 | /** |
||
36 | * Gets the expires date for your BankID certificate. If you don't |
||
37 | * have your own BankID certificate it will return Bad request. |
||
38 | * |
||
39 | * @return object |
||
40 | */ |
||
41 | 1 | public function getCertExpiry() |
|
42 | { |
||
43 | // make the URL for this request |
||
44 | 1 | $url = sprintf('%s/CertificateExpires', $this->getBaseUrl()); |
|
45 | |||
46 | // get the headers for this request |
||
47 | 1 | $headers = $this->headers->make('GET', $url); |
|
48 | |||
49 | // get the response |
||
50 | 1 | $response = $this->client->get($url, [ |
|
51 | 1 | 'headers' => $headers, |
|
52 | ]); |
||
53 | |||
54 | // return the response |
||
55 | 1 | return $response; |
|
56 | } |
||
57 | |||
58 | /** |
||
59 | * Get the usage when using prepaid or demo account. |
||
60 | * |
||
61 | * @param string $providerId |
||
62 | * @param bool|bool $demo |
||
63 | * @return object |
||
64 | */ |
||
65 | 2 | View Code Duplication | public function getUsage(string $providerId, bool $demo = false) |
66 | { |
||
67 | // make the URL for this request |
||
68 | 2 | $url = sprintf( |
|
69 | 2 | '%s/quota/%s?ProviderId=%s', |
|
70 | 2 | $this->getBaseUrl(), |
|
71 | 2 | $demo ? 'demo' : 'prepaid', |
|
72 | 2 | $providerId |
|
73 | ); |
||
74 | |||
75 | // get the headers for this request |
||
76 | 2 | $headers = $this->headers->make('GET', $url); |
|
77 | |||
78 | // get the response |
||
79 | 2 | $response = $this->client->get($url, [ |
|
80 | 2 | 'headers' => $headers, |
|
81 | ]); |
||
82 | |||
83 | // return the response |
||
84 | 2 | return $response; |
|
85 | } |
||
86 | |||
87 | /** |
||
88 | * Creates a new document provider. |
||
89 | * |
||
90 | * @param array $body |
||
91 | * @return object |
||
92 | */ |
||
93 | 1 | public function create(array $body) |
|
94 | { |
||
95 | // keys that are mandatory for this request |
||
96 | $needKeys = [ |
||
97 | 1 | 'BillingAddress1', |
|
98 | 'BillingCity', |
||
99 | 'BillingPostalCode', |
||
100 | 'CompanyEmail', |
||
101 | 'CompanyPhone', |
||
102 | 'DealerId', |
||
103 | 'LegalContactEmail', |
||
104 | 'LegalContactName', |
||
105 | 'LegalContactPhone', |
||
106 | 'MvaNumber', |
||
107 | 'Name', |
||
108 | ]; |
||
109 | |||
110 | // if the body doesn't have needed fields, throw an exception |
||
111 | 1 | $this->validateHasKeys($body, $needKeys); |
|
112 | |||
113 | 1 | View Code Duplication | if (isset($body['BillingPlan'])) { |
0 ignored issues
–
show
|
|||
114 | 1 | $expected = ['Small', 'Medium', 'Large']; |
|
115 | 1 | if (! in_array($body['BillingPlan'], $expected)) { |
|
116 | 1 | throw new UnexpectedValueException('BillingPlan should be one of '.implode(', ', $expected)); |
|
117 | } |
||
118 | } |
||
119 | |||
120 | // make the URL for this request |
||
121 | 1 | $url = $this->getBaseUrl(); |
|
122 | |||
123 | // get the response |
||
124 | 1 | $response = $this->client->post($url, [ |
|
125 | 1 | 'json' => $body, |
|
126 | ]); |
||
127 | |||
128 | // return the response |
||
129 | 1 | return $response; |
|
130 | } |
||
131 | |||
132 | /** |
||
133 | * Updates a new document provider. |
||
134 | * |
||
135 | * @param array $body |
||
136 | * @return object |
||
137 | */ |
||
138 | 1 | public function update(array $body) |
|
139 | { |
||
140 | // keys that are mandatory for this request |
||
141 | 1 | $needKeys = ['Mobile', 'ProviderId']; |
|
142 | |||
143 | // if the body doesn't have needed fields, throw an exception |
||
144 | 1 | $this->validateHasKeys($body, $needKeys); |
|
145 | |||
146 | 1 | View Code Duplication | if (isset($body['BillingPlan'])) { |
0 ignored issues
–
show
This code seems to be duplicated across your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. ![]() |
|||
147 | $expected = ['Small', 'Medium', 'Large']; |
||
148 | if (! in_array($body['BillingPlan'], $expected)) { |
||
149 | throw new UnexpectedValueException('BillingPlan should be one of '.implode(', ', $expected)); |
||
150 | } |
||
151 | } |
||
152 | |||
153 | // make the URL for this request |
||
154 | 1 | $url = $this->getBaseUrl(); |
|
155 | |||
156 | // get the headers for this request |
||
157 | 1 | $headers = $this->headers->make('PUT', $url, $body, true); |
|
158 | |||
159 | // get the response |
||
160 | 1 | $response = $this->client->put($url, [ |
|
161 | 1 | 'headers' => $headers, |
|
162 | 1 | 'json' => $body, |
|
163 | ]); |
||
164 | |||
165 | // return the response |
||
166 | 1 | return $response; |
|
167 | } |
||
168 | } |
||
169 |
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.