@@ -273,7 +273,7 @@ |
||
| 273 | 273 | 'debug' => $this->remotePlusDebug, |
| 274 | 274 | 'version' => $this->remotePlusHttpVersion, |
| 275 | 275 | 'headers' => [ 'Content-Type' => $this->remotePlusContentType, |
| 276 | - 'Authorization' => $this->getAuthenticationHeaderValue( $this->user, $this->pass ), ], |
|
| 276 | + 'Authorization' => $this->getAuthenticationHeaderValue( $this->user, $this->pass ), ], |
|
| 277 | 277 | 'body' => $this->requestBody, |
| 278 | 278 | ] ); |
| 279 | 279 | } |
@@ -98,15 +98,15 @@ discard block |
||
| 98 | 98 | * @param $user string The username given to you by Interactive Data |
| 99 | 99 | * @param $pass string The password for the above username. |
| 100 | 100 | */ |
| 101 | - public function __construct( $user, $pass ) { |
|
| 101 | + public function __construct($user, $pass) { |
|
| 102 | 102 | $this->user = $user; |
| 103 | 103 | $this->pass = $pass; |
| 104 | - $this->client = new Client( [ 'base_uri' => self::BASE_URI ] ); |
|
| 105 | - $this->authorizationHeaderValue = $this->getAuthenticationHeaderValue( $this->user, $this->pass ); |
|
| 104 | + $this->client = new Client(['base_uri' => self::BASE_URI]); |
|
| 105 | + $this->authorizationHeaderValue = $this->getAuthenticationHeaderValue($this->user, $this->pass); |
|
| 106 | 106 | } |
| 107 | 107 | |
| 108 | - public static function instantiate( string $user, string $pass ) { |
|
| 109 | - return new static( $user, $pass ); |
|
| 108 | + public static function instantiate(string $user, string $pass) { |
|
| 109 | + return new static($user, $pass); |
|
| 110 | 110 | } |
| 111 | 111 | |
| 112 | 112 | /** |
@@ -114,9 +114,9 @@ discard block |
||
| 114 | 114 | * @param array $identifiers An array of security identifiers that you want to retrieve data on. |
| 115 | 115 | * @return $this |
| 116 | 116 | */ |
| 117 | - public function addIdentifiers( array $identifiers ) { |
|
| 118 | - foreach ( $identifiers as $identifier ): |
|
| 119 | - $this->addIdentifier( $identifier ); |
|
| 117 | + public function addIdentifiers(array $identifiers) { |
|
| 118 | + foreach ($identifiers as $identifier): |
|
| 119 | + $this->addIdentifier($identifier); |
|
| 120 | 120 | endforeach; |
| 121 | 121 | return $this; |
| 122 | 122 | } |
@@ -126,9 +126,9 @@ discard block |
||
| 126 | 126 | * @param string $identifier |
| 127 | 127 | * @return $this |
| 128 | 128 | */ |
| 129 | - public function addIdentifier( string $identifier ) { |
|
| 130 | - if ( FALSE == $this->identifierExists( $identifier ) ): |
|
| 131 | - $this->identifiers[] = trim( $identifier ); |
|
| 129 | + public function addIdentifier(string $identifier) { |
|
| 130 | + if (FALSE == $this->identifierExists($identifier)): |
|
| 131 | + $this->identifiers[] = trim($identifier); |
|
| 132 | 132 | endif; |
| 133 | 133 | return $this; |
| 134 | 134 | } |
@@ -138,8 +138,8 @@ discard block |
||
| 138 | 138 | * @param string $identifier |
| 139 | 139 | * @return bool |
| 140 | 140 | */ |
| 141 | - protected function identifierExists( string $identifier ): bool { |
|
| 142 | - if ( FALSE === array_search( $identifier, $this->identifiers ) ): |
|
| 141 | + protected function identifierExists(string $identifier): bool { |
|
| 142 | + if (FALSE === array_search($identifier, $this->identifiers)): |
|
| 143 | 143 | return FALSE; |
| 144 | 144 | endif; |
| 145 | 145 | return TRUE; |
@@ -150,9 +150,9 @@ discard block |
||
| 150 | 150 | * @param array $cusips An array of CUSIP security identifiers. |
| 151 | 151 | * @return $this |
| 152 | 152 | */ |
| 153 | - public function addCusips( array $cusips ) { |
|
| 154 | - foreach ( $cusips as $cusip ): |
|
| 155 | - $this->addCusip( $cusip ); |
|
| 153 | + public function addCusips(array $cusips) { |
|
| 154 | + foreach ($cusips as $cusip): |
|
| 155 | + $this->addCusip($cusip); |
|
| 156 | 156 | endforeach; |
| 157 | 157 | return $this; |
| 158 | 158 | } |
@@ -163,9 +163,9 @@ discard block |
||
| 163 | 163 | * @param string $cusip A CUSIP security identifier. |
| 164 | 164 | * @return $this |
| 165 | 165 | */ |
| 166 | - public function addCusip( string $cusip ) { |
|
| 167 | - if ( CUSIP::isCUSIP( $cusip ) ): |
|
| 168 | - $this->addIdentifier( $cusip ); |
|
| 166 | + public function addCusip(string $cusip) { |
|
| 167 | + if (CUSIP::isCUSIP($cusip)): |
|
| 168 | + $this->addIdentifier($cusip); |
|
| 169 | 169 | endif; |
| 170 | 170 | return $this; |
| 171 | 171 | } |
@@ -176,8 +176,8 @@ discard block |
||
| 176 | 176 | * @param string $item |
| 177 | 177 | * @return $this |
| 178 | 178 | */ |
| 179 | - public function addItem( string $item ) { |
|
| 180 | - if ( FALSE === $this->itemExists( $item ) ): |
|
| 179 | + public function addItem(string $item) { |
|
| 180 | + if (FALSE === $this->itemExists($item)): |
|
| 181 | 181 | $this->items[] = $item; |
| 182 | 182 | endif; |
| 183 | 183 | return $this; |
@@ -188,9 +188,9 @@ discard block |
||
| 188 | 188 | * @param array $items |
| 189 | 189 | * @return $this |
| 190 | 190 | */ |
| 191 | - public function addItems( array $items ) { |
|
| 192 | - foreach ( $items as $item ): |
|
| 193 | - $this->addItem( $item ); |
|
| 191 | + public function addItems(array $items) { |
|
| 192 | + foreach ($items as $item): |
|
| 193 | + $this->addItem($item); |
|
| 194 | 194 | endforeach; |
| 195 | 195 | return $this; |
| 196 | 196 | } |
@@ -200,8 +200,8 @@ discard block |
||
| 200 | 200 | * @param string $item |
| 201 | 201 | * @return bool |
| 202 | 202 | */ |
| 203 | - protected function itemExists( string $item ): bool { |
|
| 204 | - if ( FALSE === array_search( $item, $this->items ) ): |
|
| 203 | + protected function itemExists(string $item): bool { |
|
| 204 | + if (FALSE === array_search($item, $this->items)): |
|
| 205 | 205 | return FALSE; |
| 206 | 206 | endif; |
| 207 | 207 | return TRUE; |
@@ -212,8 +212,8 @@ discard block |
||
| 212 | 212 | * @return $this |
| 213 | 213 | * @throws DateSentToConstructorIsNotParsable |
| 214 | 214 | */ |
| 215 | - public function addDate( string $date ) { |
|
| 216 | - $this->date = $this->formatDateForRemotePlus( $date ); |
|
| 215 | + public function addDate(string $date) { |
|
| 216 | + $this->date = $this->formatDateForRemotePlus($date); |
|
| 217 | 217 | return $this; |
| 218 | 218 | } |
| 219 | 219 | |
@@ -221,7 +221,7 @@ discard block |
||
| 221 | 221 | * @param bool $debug |
| 222 | 222 | * @return $this |
| 223 | 223 | */ |
| 224 | - public function setDebug( bool $debug ) { |
|
| 224 | + public function setDebug(bool $debug) { |
|
| 225 | 225 | $this->remotePlusDebug = $debug; |
| 226 | 226 | return $this; |
| 227 | 227 | } |
@@ -235,8 +235,8 @@ discard block |
||
| 235 | 235 | * |
| 236 | 236 | * @return string The value needed for the Authorization header. |
| 237 | 237 | */ |
| 238 | - protected function getAuthenticationHeaderValue( $username, $pass ) { |
|
| 239 | - return "Basic " . $this->encodeUserAndPassForBasicAuthentication( $username, $pass ); |
|
| 238 | + protected function getAuthenticationHeaderValue($username, $pass) { |
|
| 239 | + return "Basic ".$this->encodeUserAndPassForBasicAuthentication($username, $pass); |
|
| 240 | 240 | } |
| 241 | 241 | |
| 242 | 242 | /** |
@@ -248,8 +248,8 @@ discard block |
||
| 248 | 248 | * |
| 249 | 249 | * @return string The base64 encoded user:pass string. |
| 250 | 250 | */ |
| 251 | - protected function encodeUserAndPassForBasicAuthentication( $username, $pass ) { |
|
| 252 | - return base64_encode( $username . ':' . $pass ); |
|
| 251 | + protected function encodeUserAndPassForBasicAuthentication($username, $pass) { |
|
| 252 | + return base64_encode($username.':'.$pass); |
|
| 253 | 253 | } |
| 254 | 254 | |
| 255 | 255 | /** |
@@ -269,13 +269,13 @@ discard block |
||
| 269 | 269 | * @throws \GuzzleHttp\Exception\GuzzleException |
| 270 | 270 | */ |
| 271 | 271 | protected function sendRequest() { |
| 272 | - $this->response = $this->client->request( 'POST', self::PAGE, [ |
|
| 272 | + $this->response = $this->client->request('POST', self::PAGE, [ |
|
| 273 | 273 | 'debug' => $this->remotePlusDebug, |
| 274 | 274 | 'version' => $this->remotePlusHttpVersion, |
| 275 | - 'headers' => [ 'Content-Type' => $this->remotePlusContentType, |
|
| 276 | - 'Authorization' => $this->getAuthenticationHeaderValue( $this->user, $this->pass ), ], |
|
| 275 | + 'headers' => ['Content-Type' => $this->remotePlusContentType, |
|
| 276 | + 'Authorization' => $this->getAuthenticationHeaderValue($this->user, $this->pass), ], |
|
| 277 | 277 | 'body' => $this->requestBody, |
| 278 | - ] ); |
|
| 278 | + ]); |
|
| 279 | 279 | } |
| 280 | 280 | |
| 281 | 281 | |
@@ -285,14 +285,14 @@ discard block |
||
| 285 | 285 | * @return string The $date parameter formatted as yyyymmdd (or in PHP's syntax: Ymd) |
| 286 | 286 | * @throws \DPRMC\IceRemotePlusClient\Exceptions\DateSentToConstructorIsNotParsable |
| 287 | 287 | */ |
| 288 | - protected function formatDateForRemotePlus( string $date ) { |
|
| 289 | - $strTime = strtotime( $date ); |
|
| 290 | - if ( $strTime === FALSE ): |
|
| 291 | - throw new DateSentToConstructorIsNotParsable( "We could not parse the date you sent to the constructor: [" . $date . "]" ); |
|
| 288 | + protected function formatDateForRemotePlus(string $date) { |
|
| 289 | + $strTime = strtotime($date); |
|
| 290 | + if ($strTime === FALSE): |
|
| 291 | + throw new DateSentToConstructorIsNotParsable("We could not parse the date you sent to the constructor: [".$date."]"); |
|
| 292 | 292 | endif; |
| 293 | - $date = date( 'Ymd', $strTime ); |
|
| 293 | + $date = date('Ymd', $strTime); |
|
| 294 | 294 | |
| 295 | - return (string)$date; |
|
| 295 | + return (string) $date; |
|
| 296 | 296 | } |
| 297 | 297 | |
| 298 | 298 | |
@@ -302,7 +302,7 @@ discard block |
||
| 302 | 302 | * @return string |
| 303 | 303 | */ |
| 304 | 304 | protected function getBodyFromResponse(): string { |
| 305 | - return (string)$this->response->getBody(); |
|
| 305 | + return (string) $this->response->getBody(); |
|
| 306 | 306 | } |
| 307 | 307 | |
| 308 | 308 | |
@@ -313,33 +313,33 @@ discard block |
||
| 313 | 313 | protected function processResponse(): RemotePlusResponse { |
| 314 | 314 | $body = $this->getBodyFromResponse(); |
| 315 | 315 | |
| 316 | - $this->checkForError( $body ); |
|
| 316 | + $this->checkForError($body); |
|
| 317 | 317 | |
| 318 | - $itemValues = explode( "\n", $body ); |
|
| 319 | - $itemValues = array_map( 'trim', $itemValues ); |
|
| 320 | - $itemValues = array_filter( $itemValues ); |
|
| 321 | - array_pop( $itemValues ); // Remove the CRC check. |
|
| 318 | + $itemValues = explode("\n", $body); |
|
| 319 | + $itemValues = array_map('trim', $itemValues); |
|
| 320 | + $itemValues = array_filter($itemValues); |
|
| 321 | + array_pop($itemValues); // Remove the CRC check. |
|
| 322 | 322 | |
| 323 | 323 | $remotePlusResponse = new RemotePlusResponse(); |
| 324 | 324 | |
| 325 | - foreach ( $this->identifiers as $i => $identifier ): |
|
| 326 | - $securityResponse = SecurityResponse::instantiate() |
|
| 327 | - ->addIdentifier( $identifier ); |
|
| 325 | + foreach ($this->identifiers as $i => $identifier): |
|
| 326 | + $securityResponse = SecurityResponse::instantiate() |
|
| 327 | + ->addIdentifier($identifier); |
|
| 328 | 328 | |
| 329 | - if ( isset( $this->date ) ): |
|
| 330 | - $securityResponse->addDate( $this->date ); |
|
| 329 | + if (isset($this->date)): |
|
| 330 | + $securityResponse->addDate($this->date); |
|
| 331 | 331 | endif; |
| 332 | 332 | |
| 333 | - $individualItemValues = explode( ',', $itemValues[ $i ] ); |
|
| 333 | + $individualItemValues = explode(',', $itemValues[$i]); |
|
| 334 | 334 | |
| 335 | - foreach ( $individualItemValues as $j => $item ): |
|
| 335 | + foreach ($individualItemValues as $j => $item): |
|
| 336 | 336 | $securityResponse->addItem( |
| 337 | - $this->items[ $j ], |
|
| 337 | + $this->items[$j], |
|
| 338 | 338 | $item |
| 339 | 339 | ); |
| 340 | 340 | endforeach; |
| 341 | 341 | |
| 342 | - $remotePlusResponse->addResponse( $securityResponse ); |
|
| 342 | + $remotePlusResponse->addResponse($securityResponse); |
|
| 343 | 343 | endforeach; |
| 344 | 344 | |
| 345 | 345 | return $remotePlusResponse; |
@@ -352,26 +352,26 @@ discard block |
||
| 352 | 352 | * @param string $body |
| 353 | 353 | * @throws RemotePlusError |
| 354 | 354 | */ |
| 355 | - protected function checkForError( string $body ) { |
|
| 355 | + protected function checkForError(string $body) { |
|
| 356 | 356 | |
| 357 | 357 | // All RemotePlus errors start with "!E |
| 358 | 358 | // So if the body does not start with those 3 characters, then no error occurred, and we can continue. |
| 359 | - if ( '"!E' != substr( $body, 0, 3 ) ): |
|
| 359 | + if ('"!E' != substr($body, 0, 3)): |
|
| 360 | 360 | return; |
| 361 | 361 | endif; |
| 362 | 362 | |
| 363 | - $itemValues = explode( "\n", $body ); |
|
| 364 | - $itemValues = array_map( 'trim', $itemValues ); |
|
| 365 | - $itemValues = array_filter( $itemValues ); |
|
| 366 | - array_pop( $itemValues ); // Remove the CRC check. |
|
| 363 | + $itemValues = explode("\n", $body); |
|
| 364 | + $itemValues = array_map('trim', $itemValues); |
|
| 365 | + $itemValues = array_filter($itemValues); |
|
| 366 | + array_pop($itemValues); // Remove the CRC check. |
|
| 367 | 367 | |
| 368 | - $errorLine = $itemValues[ 0 ]; |
|
| 369 | - $errorParts = explode( '","', $errorLine ); |
|
| 370 | - $errorParts = array_map( function ( $item ) { |
|
| 371 | - return trim( $item, '"' ); |
|
| 372 | - }, $errorParts ); |
|
| 368 | + $errorLine = $itemValues[0]; |
|
| 369 | + $errorParts = explode('","', $errorLine); |
|
| 370 | + $errorParts = array_map(function($item) { |
|
| 371 | + return trim($item, '"'); |
|
| 372 | + }, $errorParts); |
|
| 373 | 373 | |
| 374 | - throw new RemotePlusError( $errorParts[ 1 ], 0, NULL, $errorParts[ 0 ] ); |
|
| 374 | + throw new RemotePlusError($errorParts[1], 0, NULL, $errorParts[0]); |
|
| 375 | 375 | } |
| 376 | 376 | |
| 377 | 377 | /** |
@@ -385,9 +385,9 @@ discard block |
||
| 385 | 385 | */ |
| 386 | 386 | protected function generateBodyForRequest() { |
| 387 | 387 | |
| 388 | - $identifiers = implode( ',', $this->identifiers ); |
|
| 389 | - $items = implode( ',', $this->items ); |
|
| 388 | + $identifiers = implode(',', $this->identifiers); |
|
| 389 | + $items = implode(',', $this->items); |
|
| 390 | 390 | |
| 391 | - $this->requestBody = 'Request=' . urlencode( "GET,(" . $identifiers ) . "),(" . $items . ")," . $this->date . "&Done=flag\n"; |
|
| 391 | + $this->requestBody = 'Request='.urlencode("GET,(".$identifiers)."),(".$items."),".$this->date."&Done=flag\n"; |
|
| 392 | 392 | } |
| 393 | 393 | } |
| 394 | 394 | \ No newline at end of file |
@@ -51,7 +51,7 @@ discard block |
||
| 51 | 51 | * @param string $identifier |
| 52 | 52 | * @return $this |
| 53 | 53 | */ |
| 54 | - public function addIdentifier( string $identifier ) { |
|
| 54 | + public function addIdentifier(string $identifier) { |
|
| 55 | 55 | $this->identifier = $identifier; |
| 56 | 56 | return $this; |
| 57 | 57 | } |
@@ -60,8 +60,8 @@ discard block |
||
| 60 | 60 | * @param string $date |
| 61 | 61 | * @return $this |
| 62 | 62 | */ |
| 63 | - public function addDate( string $date ) { |
|
| 64 | - $this->date = Carbon::parse( $date ); |
|
| 63 | + public function addDate(string $date) { |
|
| 64 | + $this->date = Carbon::parse($date); |
|
| 65 | 65 | return $this; |
| 66 | 66 | } |
| 67 | 67 | |
@@ -80,8 +80,8 @@ discard block |
||
| 80 | 80 | * “!N7” an error code 7000 was returned |
| 81 | 81 | * “!N8” an error code 8000 was returned |
| 82 | 82 | */ |
| 83 | - public function addItem( string $code, $value = NULL ) { |
|
| 84 | - $this->items[ $code ] = trim( $value, ' "' ); |
|
| 83 | + public function addItem(string $code, $value = NULL) { |
|
| 84 | + $this->items[$code] = trim($value, ' "'); |
|
| 85 | 85 | return $this; |
| 86 | 86 | } |
| 87 | 87 | |
@@ -90,8 +90,8 @@ discard block |
||
| 90 | 90 | * @param string $item |
| 91 | 91 | * @return bool |
| 92 | 92 | */ |
| 93 | - protected function itemExists( string $item ): bool { |
|
| 94 | - if ( isset( $this->items[ $item ] ) ): |
|
| 93 | + protected function itemExists(string $item): bool { |
|
| 94 | + if (isset($this->items[$item])): |
|
| 95 | 95 | return TRUE; |
| 96 | 96 | endif; |
| 97 | 97 | return FALSE; |
@@ -112,14 +112,14 @@ discard block |
||
| 112 | 112 | * @note From Client Support at ICE Data Services: unfortunately we don't have examples for the others (!NR, !N5, !N6, !N7, and !N8). |
| 113 | 113 | * ...so as a result those Exceptions can't be tested with our unit tests. |
| 114 | 114 | */ |
| 115 | - public function getItem( string $item ) { |
|
| 116 | - if ( FALSE === $this->itemExists( $item ) ): |
|
| 115 | + public function getItem(string $item) { |
|
| 116 | + if (FALSE === $this->itemExists($item)): |
|
| 117 | 117 | throw new ItemDoesNotExistInSecurityResponse(); |
| 118 | 118 | endif; |
| 119 | 119 | |
| 120 | - $value = $this->items[ $item ]; |
|
| 120 | + $value = $this->items[$item]; |
|
| 121 | 121 | |
| 122 | - switch ( $value ): |
|
| 122 | + switch ($value): |
|
| 123 | 123 | case '!NA': |
| 124 | 124 | throw new ItemValueNotAvailable(); |
| 125 | 125 | case '!NH': |
@@ -25,7 +25,7 @@ discard block |
||
| 25 | 25 | * "Setter" method to add a SecurityResponse object to our array of objects. |
| 26 | 26 | * @param SecurityResponse $response |
| 27 | 27 | */ |
| 28 | - public function addResponse( SecurityResponse $response ){ |
|
| 28 | + public function addResponse(SecurityResponse $response) { |
|
| 29 | 29 | $this->responses[$response->identifier] = $response; |
| 30 | 30 | } |
| 31 | 31 | |
@@ -33,7 +33,7 @@ discard block |
||
| 33 | 33 | * Simple getter method to get an array of all the SecurityResponse objects. |
| 34 | 34 | * @return array |
| 35 | 35 | */ |
| 36 | - public function getResponses(){ |
|
| 36 | + public function getResponses() { |
|
| 37 | 37 | return $this->responses; |
| 38 | 38 | } |
| 39 | 39 | |
@@ -49,7 +49,7 @@ discard block |
||
| 49 | 49 | /** |
| 50 | 50 | * @var SecurityResponse $response |
| 51 | 51 | */ |
| 52 | - foreach($this->responses as $response): |
|
| 52 | + foreach ($this->responses as $response): |
|
| 53 | 53 | $valuesToReturn[$response->identifier] = $response->items[$item]; |
| 54 | 54 | endforeach; |
| 55 | 55 | |
@@ -25,8 +25,8 @@ |
||
| 25 | 25 | * @param Throwable|NULL $previous |
| 26 | 26 | * @param string|NULL $remotePlusErrorCode |
| 27 | 27 | */ |
| 28 | - public function __construct( string $message = "", int $code = 0, Throwable $previous = NULL, string $remotePlusErrorCode=null ) { |
|
| 29 | - parent::__construct( $message, $code, $previous ); |
|
| 28 | + public function __construct(string $message = "", int $code = 0, Throwable $previous = NULL, string $remotePlusErrorCode = null) { |
|
| 29 | + parent::__construct($message, $code, $previous); |
|
| 30 | 30 | $this->remotePlusErrorCode = $remotePlusErrorCode; |
| 31 | 31 | } |
| 32 | 32 | } |
| 33 | 33 | \ No newline at end of file |