unicodeveloper /
jusibe-php-lib
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 | * This file is part of the Jusibe PHP library. |
||
| 4 | * |
||
| 5 | * (c) Prosper Otemuyiwa <[email protected]> |
||
| 6 | * |
||
| 7 | * For the full copyright and license information, please view the LICENSE |
||
| 8 | * file that was distributed with this source code. |
||
| 9 | */ |
||
| 10 | |||
| 11 | namespace Unicodeveloper\Jusibe; |
||
| 12 | |||
| 13 | use StdClass; |
||
| 14 | use Dotenv\Dotenv; |
||
| 15 | use GuzzleHttp\Client; |
||
| 16 | use Unicodeveloper\Jusibe\Exceptions\IsEmpty; |
||
| 17 | |||
| 18 | trait Helper { |
||
| 19 | |||
| 20 | /** |
||
| 21 | * Load Dotenv to grant getenv() access to environment variables in .env file. |
||
| 22 | */ |
||
| 23 | public function loadEnv() |
||
| 24 | { |
||
| 25 | if (! getenv('APP_ENV')) { |
||
| 26 | $dotenv = new Dotenv(__DIR__.'/../'); |
||
|
0 ignored issues
–
show
Bug
introduced
by
Loading history...
__DIR__ . '/../' is of type string, but the function expects a object<Dotenv\Loader\LoaderInterface>.
It seems like the type of the argument is not accepted by the function/method which you are calling. In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug. We suggest to add an explicit type cast like in the following example: function acceptsInteger($int) { }
$x = '123'; // string "123"
// Instead of
acceptsInteger($x);
// we recommend to use
acceptsInteger((integer) $x);
Loading history...
|
|||
| 27 | $dotenv->load(); |
||
| 28 | } |
||
| 29 | } |
||
| 30 | |||
| 31 | /** |
||
| 32 | * Get Valid Message ID |
||
| 33 | * @return string |
||
| 34 | */ |
||
| 35 | public function getValidMessageID() |
||
| 36 | { |
||
| 37 | return getenv('VALID_MESSAGE_ID'); |
||
| 38 | } |
||
| 39 | |||
| 40 | /** |
||
| 41 | * Get Valid Bulk Message ID |
||
| 42 | * @return string |
||
| 43 | */ |
||
| 44 | public function getValidBulkMessageID() |
||
| 45 | { |
||
| 46 | return getenv('BULK_MESSAGE_ID'); |
||
| 47 | } |
||
| 48 | |||
| 49 | /** |
||
| 50 | * Get Invalid Message ID |
||
| 51 | * @return string |
||
| 52 | */ |
||
| 53 | public function getInvalidMessageID() |
||
| 54 | { |
||
| 55 | return getenv('INVALID_MESSAGE_ID'); |
||
| 56 | } |
||
| 57 | |||
| 58 | /** |
||
| 59 | * Get Valid Access Token |
||
| 60 | * @return string |
||
| 61 | */ |
||
| 62 | public function getValidAccessToken() |
||
| 63 | { |
||
| 64 | return getenv('VALID_ACCESS_TOKEN'); |
||
| 65 | } |
||
| 66 | |||
| 67 | /** |
||
| 68 | * Stubbed checkDeliveryStatusResponse |
||
| 69 | * @return object |
||
| 70 | */ |
||
| 71 | public function checkDeliveryStatusResponse() |
||
| 72 | { |
||
| 73 | $response = new StdClass; |
||
| 74 | $response->message_id = $this->getValidMessageID(); |
||
| 75 | $response->status = 'Delivered'; |
||
| 76 | $response->date_sent = time(); |
||
| 77 | $response->date_delivered = time(); |
||
| 78 | |||
| 79 | return $response; |
||
| 80 | } |
||
| 81 | |||
| 82 | /** |
||
| 83 | * Stubbed checkBulkDeliveryStatusResponse |
||
| 84 | * @return object |
||
| 85 | */ |
||
| 86 | public function checkBulkDeliveryStatusResponse() |
||
| 87 | { |
||
| 88 | $response = new StdClass; |
||
| 89 | $response->bulk_message_id = $this->getValidBulkMessageID(); |
||
| 90 | $response->status = 'Completed'; |
||
| 91 | $response->created = time(); |
||
| 92 | $response->processed = time(); |
||
| 93 | $response->total_numbers = 2; |
||
| 94 | $response->total_unique_numbers = 2; |
||
| 95 | $response->total_valid_numbers = 2; |
||
| 96 | $response->total_invalid_numbers = 0; |
||
| 97 | |||
| 98 | return $response; |
||
| 99 | } |
||
| 100 | |||
| 101 | /** |
||
| 102 | * Stubbed Invalid Keys Response |
||
| 103 | * @return object |
||
| 104 | */ |
||
| 105 | public function invalidKeysResponse() |
||
| 106 | { |
||
| 107 | $response = new StdClass; |
||
| 108 | $response->error = "Invalid API Key!"; |
||
| 109 | |||
| 110 | return $response; |
||
| 111 | } |
||
| 112 | |||
| 113 | /** |
||
| 114 | * Stubbed Invalid Message ID Response |
||
| 115 | * @return object |
||
| 116 | */ |
||
| 117 | public function invalidMessageIDResponse() |
||
| 118 | { |
||
| 119 | $response = new StdClass; |
||
| 120 | $response->invalid_message_id = "Invalid message ID"; |
||
| 121 | |||
| 122 | return $response; |
||
| 123 | } |
||
| 124 | |||
| 125 | /** |
||
| 126 | * Stubbed sendSMSResponse |
||
| 127 | * @return object |
||
| 128 | */ |
||
| 129 | public function sendSMSResponse() |
||
| 130 | { |
||
| 131 | $response = new StdClass; |
||
| 132 | $response->status = 'Sent'; |
||
| 133 | $response->message_id = $this->getValidMessageID(); |
||
| 134 | $response->sms_credits_used = 1; |
||
| 135 | |||
| 136 | return $response; |
||
| 137 | } |
||
| 138 | |||
| 139 | /** |
||
| 140 | * Stubbed sendBulkSMSResponse |
||
| 141 | * @return object |
||
| 142 | */ |
||
| 143 | public function sendBulkSMSResponse() |
||
| 144 | { |
||
| 145 | $response = new StdClass; |
||
| 146 | $response->status = 'Submitted'; |
||
| 147 | $response->bulk_message_id = $this->getValidBulkMessageID(); |
||
| 148 | $response->request_speed = 0.05; |
||
| 149 | |||
| 150 | return $response; |
||
| 151 | } |
||
| 152 | |||
| 153 | /** |
||
| 154 | * Stubbed checkAvailableCreditsResponse |
||
| 155 | * @return object |
||
| 156 | */ |
||
| 157 | public function checkAvailableCreditsResponse() |
||
| 158 | { |
||
| 159 | $response = new StdClass; |
||
| 160 | $response->sms_credits = 200; |
||
| 161 | |||
| 162 | return $response; |
||
| 163 | } |
||
| 164 | |||
| 165 | /** |
||
| 166 | * Stubbed correct Payload |
||
| 167 | * @return array |
||
| 168 | */ |
||
| 169 | public function correctPayload() |
||
| 170 | { |
||
| 171 | $message = "I LOVE YOU, BABY"; |
||
| 172 | |||
| 173 | return [ |
||
| 174 | 'to' => '8038142771', |
||
| 175 | 'from' => 'TEST JUSIBE', |
||
| 176 | 'message' => $message |
||
| 177 | ]; |
||
| 178 | } |
||
| 179 | |||
| 180 | /** |
||
| 181 | * Get Invalid Access Token |
||
| 182 | * @return string |
||
| 183 | */ |
||
| 184 | public function getInvalidAccessToken() |
||
| 185 | { |
||
| 186 | return getenv('INVALID_ACCESS_TOKEN'); |
||
| 187 | } |
||
| 188 | |||
| 189 | /** |
||
| 190 | * Get Valid Public Key |
||
| 191 | * @return string |
||
| 192 | */ |
||
| 193 | public function getValidPublicKey() |
||
| 194 | { |
||
| 195 | return getenv('VALID_PUBLIC_KEY'); |
||
| 196 | } |
||
| 197 | |||
| 198 | /** |
||
| 199 | * Get Valid Public Key |
||
| 200 | * @return string |
||
| 201 | */ |
||
| 202 | public function getInvalidPublicKey() |
||
| 203 | { |
||
| 204 | return getenv('INVALID_PUBLIC_KEY'); |
||
| 205 | } |
||
| 206 | } |
||
| 207 | |||
| 208 | |||
| 209 |