From 4f551cf0fce2d4e77c48d0d90144936f77cf53c6 Mon Sep 17 00:00:00 2001
From: Selim Salihovic <selim.salihovic@gmail.com>
Date: Tue, 23 May 2017 20:50:02 +0200
Subject: [PATCH 1/4] Set the defaults outside the constructor

---
 src/Bitpay/Invoice.php | 18 ++++--------------
 1 file changed, 4 insertions(+), 14 deletions(-)

diff --git a/src/Bitpay/Invoice.php b/src/Bitpay/Invoice.php
index 254037b1..9cf0b1dc 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 = false;
 
     /**
      * @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
      */

From 71b8805de66376f2692b8421fee2257a14f756ff Mon Sep 17 00:00:00 2001
From: Selim Salihovic <selim.salihovic@gmail.com>
Date: Tue, 23 May 2017 20:50:10 +0200
Subject: [PATCH 2/4] Add missing methods to mock

---
 tests/Bitpay/Client/ClientTest.php | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

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();

From 925cf6b5a89965904d4c3ddaeff47fe5c29f5cd4 Mon Sep 17 00:00:00 2001
From: Selim Salihovic <selim.salihovic@gmail.com>
Date: Tue, 23 May 2017 20:59:49 +0200
Subject: [PATCH 3/4] Use the proper default for fullNotifications

---
 src/Bitpay/Invoice.php       | 2 +-
 tests/Bitpay/InvoiceTest.php | 6 +++---
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/src/Bitpay/Invoice.php b/src/Bitpay/Invoice.php
index 9cf0b1dc..0b5115bf 100644
--- a/src/Bitpay/Invoice.php
+++ b/src/Bitpay/Invoice.php
@@ -60,7 +60,7 @@ class Invoice implements InvoiceInterface
     /**
      * @var boolean
      */
-    protected $fullNotifications = false;
+    protected $fullNotifications = true;
 
     /**
      * @var boolean
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()

From ed8cb7239b1fbc38dba3b2c56851806256e6c5b5 Mon Sep 17 00:00:00 2001
From: Selim Salihovic <selim.salihovic@gmail.com>
Date: Tue, 23 May 2017 21:10:04 +0200
Subject: [PATCH 4/4] PSR fixes

---
 src/Bitpay/Client/Response.php | 18 ++++++++++--------
 src/Bitpay/Invoice.php         |  1 -
 src/Bitpay/User.php            |  1 -
 3 files changed, 10 insertions(+), 10 deletions(-)

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 0b5115bf..70cff6ec 100644
--- a/src/Bitpay/Invoice.php
+++ b/src/Bitpay/Invoice.php
@@ -746,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;
     }
-
 }
