diff --git a/src/Bitpay/Client/Response.php b/src/Bitpay/Client/Response.php index 65c7f50a..cc378586 100644 --- a/src/Bitpay/Client/Response.php +++ b/src/Bitpay/Client/Response.php @@ -52,17 +52,19 @@ public function __toString() } /** + * @param string $rawResponse + * @return Response */ public static function createFromRawResponse($rawResponse) - { + { $response = new self($rawResponse); - // remove HTTP 100 responses - $delimiter = "\r\n\r\n"; // HTTP header delimiter - // check if the 100 Continue header exists - while ( preg_match('#^HTTP/[0-9\\.]+\s+100\s+Continue#i',$rawResponse) ) { - $tmp = explode($delimiter,$rawResponse,2); // grab the 100 Continue header - $rawResponse = $tmp[1]; // update the response, purging the most recent 100 Continue header - } // repeat + //remove HTTP 100 responses + $delimiter = "\r\n\r\n";// HTTP header delimiter + //check if the 100 Continue header exists + while (preg_match('#^HTTP/[0-9\\.]+\s+100\s+Continue#i', $rawResponse)) { + $tmp = explode($delimiter, $rawResponse, 2);// grab the 100 Continue header + $rawResponse = $tmp[1];// update the response, purging the most recent 100 Continue header + }// repeat $lines = preg_split('/(\\r?\\n)/', $rawResponse); $linesLen = count($lines); diff --git a/src/Bitpay/Invoice.php b/src/Bitpay/Invoice.php index 254037b1..70cff6ec 100644 --- a/src/Bitpay/Invoice.php +++ b/src/Bitpay/Invoice.php @@ -30,7 +30,7 @@ class Invoice implements InvoiceInterface /** * @var string */ - protected $transactionSpeed; + protected $transactionSpeed = self::TRANSACTION_SPEED_MEDIUM; /** * @var string @@ -60,12 +60,12 @@ class Invoice implements InvoiceInterface /** * @var boolean */ - protected $fullNotifications; + protected $fullNotifications = true; /** * @var boolean */ - protected $extendedNotifications; + protected $extendedNotifications = false; /** * @var string @@ -123,20 +123,10 @@ class Invoice implements InvoiceInterface protected $token; /** - * @var Array + * @var array */ protected $refundAddresses; - - /** - */ - public function __construct() - { - $this->transactionSpeed = self::TRANSACTION_SPEED_MEDIUM; - $this->fullNotifications = true; - $this->extendedNotifications = false; - } - /** * @inheritdoc */ @@ -756,5 +746,4 @@ public function setRefundAddresses($refundAddresses) return $this; } - } diff --git a/src/Bitpay/User.php b/src/Bitpay/User.php index 35cae15b..cf54b406 100644 --- a/src/Bitpay/User.php +++ b/src/Bitpay/User.php @@ -306,5 +306,4 @@ public function setNotify($boolvalue) return $this; } - } diff --git a/tests/Bitpay/Client/ClientTest.php b/tests/Bitpay/Client/ClientTest.php index 5aacf18d..c8d9ccbe 100644 --- a/tests/Bitpay/Client/ClientTest.php +++ b/tests/Bitpay/Client/ClientTest.php @@ -622,9 +622,9 @@ private function getMockInvoice() 'getExpirationTime', 'getCurrentTime', 'getOrderId', 'getItemDesc', 'getItemCode', 'isPhysical', 'getBuyerName', 'getBuyerAddress1', 'getBuyerAddress2', 'getBuyerCity', 'getBuyerState', 'getBuyerZip', 'getBuyerCountry', 'getBuyerEmail', 'getBuyerPhone', - 'getExceptionStatus', 'getBtcPaid', 'getRate', 'getToken', 'setId', 'setUrl', - 'setStatus', 'setBtcPrice', 'setPrice', 'setInvoiceTime', 'setExpirationTime', - 'setCurrentTime', 'setBtcPaid', 'setRate', 'setToken', 'setExceptionStatus', + 'getExceptionStatus', 'getBtcPaid', 'getRate', 'getToken', 'getRefundAddresses', + 'setId', 'setUrl', 'setStatus', 'setBtcPrice', 'setPrice', 'setInvoiceTime', 'setExpirationTime', + 'setCurrentTime', 'setBtcPaid', 'setRate', 'setToken', 'setExceptionStatus', 'isExtendedNotifications' ) ) ->getMock(); @@ -688,6 +688,7 @@ private function getMockBuyer() 'getState', 'getZip', 'getCountry', + 'getNotify' ) ) ->getMock(); diff --git a/tests/Bitpay/InvoiceTest.php b/tests/Bitpay/InvoiceTest.php index 9eab65ea..e3d1a9e6 100644 --- a/tests/Bitpay/InvoiceTest.php +++ b/tests/Bitpay/InvoiceTest.php @@ -181,7 +181,7 @@ public function testSetStatus() public function testIsFullNotifications() { $this->assertNotNull($this->invoice); - $this->assertFalse($this->invoice->isFullNotifications()); + $this->assertTrue($this->invoice->isFullNotifications()); } public function testGetId() @@ -523,9 +523,9 @@ public function testSetToken() public function testSetFullNotifications() { - $this->assertFalse($this->invoice->isFullNotifications()); - $this->invoice->setFullNotifications(true); $this->assertTrue($this->invoice->isFullNotifications()); + $this->invoice->setFullNotifications(false); + $this->assertFalse($this->invoice->isFullNotifications()); } private function getMockItem()