Completed
Pull Request — master (#24)
by Laurens
03:00
created
src/Client/PurchaseClient.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -17,8 +17,8 @@
 block discarded – undo
17 17
 {
18 18
     const BASE_URL = 'https://purchase.izettle.com';
19 19
 
20
-    const GET_PURCHASE = self::BASE_URL . '/purchase/v2/%s';
21
-    const GET_PURCHASES = self::BASE_URL . '/purchases/v2';
20
+    const GET_PURCHASE = self::BASE_URL.'/purchase/v2/%s';
21
+    const GET_PURCHASES = self::BASE_URL.'/purchases/v2';
22 22
 
23 23
     private $client;
24 24
     private $purchaseHistoryBuilder;
Please login to merge, or discard this patch.
src/Client/Purchase/PaymentBuilder.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -53,7 +53,7 @@
 block discarded – undo
53 53
                 return $this->parseVippsPayment($payment, $currency);
54 54
         }
55 55
 
56
-        throw new PaymentTypeNotConfiguredException('Payment type \'' . $payment['type'] . '\' not configured');
56
+        throw new PaymentTypeNotConfiguredException('Payment type \''.$payment['type'].'\' not configured');
57 57
     }
58 58
 
59 59
     private function parseCardPayment($payment, Currency $currency): CardPayment
Please login to merge, or discard this patch.
src/Client/Purchase/PurchaseHistoryBuilder.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -18,7 +18,7 @@
 block discarded – undo
18 18
 
19 19
     public function buildFromJson(string $jsonData): PurchaseHistory
20 20
     {
21
-        $data =  json_decode($jsonData, true);
21
+        $data = json_decode($jsonData, true);
22 22
 
23 23
         return new PurchaseHistory(
24 24
             $data['firstPurchaseHash'],
Please login to merge, or discard this patch.
src/GuzzleIzettleClient.php 2 patches
Indentation   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -65,26 +65,26 @@
 block discarded – undo
65 65
     }
66 66
 
67 67
     
68
-	public function getAccessTokenFromAuthorizedCode(string $redirectUrl, string $code ): AccessToken
69
-	{
70
-		$options = [
71
-		   'form_params' => [
72
-			  'grant_type' => self::API_ACCESS_TOKEN_CODE_GRANT,
73
-			  'client_id' => $this->clientId,
74
-			  'client_secret' => $this->clientSecret,
75
-			  'redirect_uri' => $redirectUrl,
76
-			  'code' => $code
77
-		   ],
78
-		];
79
-
80
-		try {
81
-			$this->setAccessToken($this->requestAccessToken(self::API_ACCESS_TOKEN_REQUEST_URL, $options));
82
-		} catch (ClientException $exception) {
83
-			GuzzleClientExceptionHandler::handleClientException($exception);
84
-		}
85
-
86
-		return $this->accessToken;
87
-	}
68
+    public function getAccessTokenFromAuthorizedCode(string $redirectUrl, string $code ): AccessToken
69
+    {
70
+        $options = [
71
+            'form_params' => [
72
+                'grant_type' => self::API_ACCESS_TOKEN_CODE_GRANT,
73
+                'client_id' => $this->clientId,
74
+                'client_secret' => $this->clientSecret,
75
+                'redirect_uri' => $redirectUrl,
76
+                'code' => $code
77
+            ],
78
+        ];
79
+
80
+        try {
81
+            $this->setAccessToken($this->requestAccessToken(self::API_ACCESS_TOKEN_REQUEST_URL, $options));
82
+        } catch (ClientException $exception) {
83
+            GuzzleClientExceptionHandler::handleClientException($exception);
84
+        }
85
+
86
+        return $this->accessToken;
87
+    }
88 88
     
89 89
     public function getAccessTokenFromUserLogin(string $username, string $password): AccessToken
90 90
     {
Please login to merge, or discard this patch.
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -56,16 +56,16 @@  discard block
 block discarded – undo
56 56
     {
57 57
         $url = self::API_AUTHORIZE_USER_LOGIN_URL;
58 58
         $url .= '?response_type=code';
59
-        $url .= '&redirect_uri=' . $redirectUrl;
60
-        $url .= '&client_id=' . $this->clientId;
61
-        $url .= '&scope=' . $apiScope->getUrlParameters();
59
+        $url .= '&redirect_uri='.$redirectUrl;
60
+        $url .= '&client_id='.$this->clientId;
61
+        $url .= '&scope='.$apiScope->getUrlParameters();
62 62
         $url .= '&state=oauth2';
63 63
 
64 64
         return $url;
65 65
     }
66 66
 
67 67
     
68
-	public function getAccessTokenFromAuthorizedCode(string $redirectUrl, string $code ): AccessToken
68
+	public function getAccessTokenFromAuthorizedCode(string $redirectUrl, string $code): AccessToken
69 69
 	{
70 70
 		$options = [
71 71
 		   'form_params' => [
@@ -107,7 +107,7 @@  discard block
 block discarded – undo
107 107
         return $this->accessToken;
108 108
     }
109 109
 
110
-    public function refreshAccessToken(?AccessToken $accessToken =  null): AccessToken
110
+    public function refreshAccessToken(?AccessToken $accessToken = null): AccessToken
111 111
     {
112 112
         $accessToken = $accessToken ?? $this->accessToken;
113 113
         $options = [
@@ -126,7 +126,7 @@  discard block
 block discarded – undo
126 126
 
127 127
     public function get(string $url, ?array $queryParameters = null): ResponseInterface
128 128
     {
129
-        $options =  array_merge(['headers' => $this->getAuthorizationHeader()], ['query' => $queryParameters]);
129
+        $options = array_merge(['headers' => $this->getAuthorizationHeader()], ['query' => $queryParameters]);
130 130
 
131 131
         try {
132 132
             $response = $this->guzzleClient->get($url, $options);
@@ -147,7 +147,7 @@  discard block
 block discarded – undo
147 147
             ]
148 148
         );
149 149
 
150
-        $options =  array_merge(['headers' => $headers], ['body' => $postable->getPostBodyData()]);
150
+        $options = array_merge(['headers' => $headers], ['body' => $postable->getPostBodyData()]);
151 151
 
152 152
         return $this->guzzleClient->post($url, $options);
153 153
     }
@@ -162,7 +162,7 @@  discard block
 block discarded – undo
162 162
             ]
163 163
         );
164 164
 
165
-        $options =  array_merge(['headers' => $headers], ['body' => $jsonData]);
165
+        $options = array_merge(['headers' => $headers], ['body' => $jsonData]);
166 166
 
167 167
         $this->guzzleClient->put($url, $options);
168 168
     }
Please login to merge, or discard this patch.
src/IzettleClientInterface.php 2 patches
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -14,7 +14,7 @@
 block discarded – undo
14 14
 
15 15
     const API_ACCESS_TOKEN_REQUEST_URL = self::API_BASE_URL . '/token';
16 16
     const API_ACCESS_TOKEN_PASSWORD_GRANT = 'password';
17
-	const API_ACCESS_TOKEN_CODE_GRANT = 'authorization_code';
17
+    const API_ACCESS_TOKEN_CODE_GRANT = 'authorization_code';
18 18
     const API_ACCESS_TOKEN_REFRESH_TOKEN_URL = self::API_BASE_URL . '/token';
19 19
     const API_ACCESS_TOKEN_REFRESH_TOKEN_GRANT = 'refresh_token';
20 20
 
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -10,12 +10,12 @@  discard block
 block discarded – undo
10 10
 interface IzettleClientInterface
11 11
 {
12 12
     const API_BASE_URL = 'https://oauth.izettle.net';
13
-    const API_AUTHORIZE_USER_LOGIN_URL = self::API_BASE_URL . '/authorize';
13
+    const API_AUTHORIZE_USER_LOGIN_URL = self::API_BASE_URL.'/authorize';
14 14
 
15
-    const API_ACCESS_TOKEN_REQUEST_URL = self::API_BASE_URL . '/token';
15
+    const API_ACCESS_TOKEN_REQUEST_URL = self::API_BASE_URL.'/token';
16 16
     const API_ACCESS_TOKEN_PASSWORD_GRANT = 'password';
17 17
 	const API_ACCESS_TOKEN_CODE_GRANT = 'authorization_code';
18
-    const API_ACCESS_TOKEN_REFRESH_TOKEN_URL = self::API_BASE_URL . '/token';
18
+    const API_ACCESS_TOKEN_REFRESH_TOKEN_URL = self::API_BASE_URL.'/token';
19 19
     const API_ACCESS_TOKEN_REFRESH_TOKEN_GRANT = 'refresh_token';
20 20
 
21 21
     public function setAccessToken(AccessToken $accessToken): void;
@@ -24,7 +24,7 @@  discard block
 block discarded – undo
24 24
 
25 25
     public function getAccessTokenFromUserLogin(string $username, string $password): AccessToken;
26 26
 
27
-    public function refreshAccessToken(?AccessToken $accessToken =  null): AccessToken;
27
+    public function refreshAccessToken(?AccessToken $accessToken = null): AccessToken;
28 28
 
29 29
     public function get(string $url, ?array $queryParameters = null): ResponseInterface;
30 30
 
Please login to merge, or discard this patch.
src/Client/ApiScope.php 3 patches
Indentation   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -68,29 +68,29 @@
 block discarded – undo
68 68
     {
69 69
         $scope = [];
70 70
         if ($this->finance !== null) {
71
-		$scope[] = $this->finance->getValue().':'.self::FINANCE;
72
-		if($this->finance->getValue() == Rights::WRITE)
73
-			$scope[] = Rights::READ.':'.self::FINANCE;
71
+        $scope[] = $this->finance->getValue().':'.self::FINANCE;
72
+        if($this->finance->getValue() == Rights::WRITE)
73
+            $scope[] = Rights::READ.':'.self::FINANCE;
74 74
         }
75 75
         if ($this->purchase !== null) {
76
-		$scope[] = $this->purchase->getValue().':'.self::PURCHASE;
77
-		if($this->purchase->getValue() == Rights::WRITE)
78
-			$scope[] = Rights::READ.':'.self::PURCHASE;
76
+        $scope[] = $this->purchase->getValue().':'.self::PURCHASE;
77
+        if($this->purchase->getValue() == Rights::WRITE)
78
+            $scope[] = Rights::READ.':'.self::PURCHASE;
79 79
         }
80 80
         if ($this->product !== null) {
81
-        	$scope[] = $this->product->getValue().':'.self::PRODUCT;
82
-		if($this->product->getValue() == Rights::WRITE)
83
-			$scope[] = Rights::READ.':'.self::PRODUCT;
81
+            $scope[] = $this->product->getValue().':'.self::PRODUCT;
82
+        if($this->product->getValue() == Rights::WRITE)
83
+            $scope[] = Rights::READ.':'.self::PRODUCT;
84 84
         }
85 85
         if ($this->inventory !== null) {
86
-		$scope[] = $this->inventory->getValue().':'.self::INVENTORY;
87
-		if($this->inventory->getValue() == Rights::WRITE)
88
-			$scope[] = Rights::READ.':'.self::INVENTORY;
86
+        $scope[] = $this->inventory->getValue().':'.self::INVENTORY;
87
+        if($this->inventory->getValue() == Rights::WRITE)
88
+            $scope[] = Rights::READ.':'.self::INVENTORY;
89 89
         }
90 90
         if ($this->image !== null) {
91
-		$scope[] = $this->image->getValue().':'.self::IMAGE;
92
-		if($this->image->getValue() == Rights::WRITE)
93
-			$scope[] = Rights::READ.':'.self::IMAGE;
91
+        $scope[] = $this->image->getValue().':'.self::IMAGE;
92
+        if($this->image->getValue() == Rights::WRITE)
93
+            $scope[] = Rights::READ.':'.self::IMAGE;
94 94
         }
95 95
         return implode(' ', $scope);
96 96
     }
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -69,27 +69,27 @@
 block discarded – undo
69 69
         $scope = [];
70 70
         if ($this->finance !== null) {
71 71
 		$scope[] = $this->finance->getValue().':'.self::FINANCE;
72
-		if($this->finance->getValue() == Rights::WRITE)
72
+		if ($this->finance->getValue() == Rights::WRITE)
73 73
 			$scope[] = Rights::READ.':'.self::FINANCE;
74 74
         }
75 75
         if ($this->purchase !== null) {
76 76
 		$scope[] = $this->purchase->getValue().':'.self::PURCHASE;
77
-		if($this->purchase->getValue() == Rights::WRITE)
77
+		if ($this->purchase->getValue() == Rights::WRITE)
78 78
 			$scope[] = Rights::READ.':'.self::PURCHASE;
79 79
         }
80 80
         if ($this->product !== null) {
81 81
         	$scope[] = $this->product->getValue().':'.self::PRODUCT;
82
-		if($this->product->getValue() == Rights::WRITE)
82
+		if ($this->product->getValue() == Rights::WRITE)
83 83
 			$scope[] = Rights::READ.':'.self::PRODUCT;
84 84
         }
85 85
         if ($this->inventory !== null) {
86 86
 		$scope[] = $this->inventory->getValue().':'.self::INVENTORY;
87
-		if($this->inventory->getValue() == Rights::WRITE)
87
+		if ($this->inventory->getValue() == Rights::WRITE)
88 88
 			$scope[] = Rights::READ.':'.self::INVENTORY;
89 89
         }
90 90
         if ($this->image !== null) {
91 91
 		$scope[] = $this->image->getValue().':'.self::IMAGE;
92
-		if($this->image->getValue() == Rights::WRITE)
92
+		if ($this->image->getValue() == Rights::WRITE)
93 93
 			$scope[] = Rights::READ.':'.self::IMAGE;
94 94
         }
95 95
         return implode(' ', $scope);
Please login to merge, or discard this patch.
Braces   +15 added lines, -10 removed lines patch added patch discarded remove patch
@@ -69,28 +69,33 @@
 block discarded – undo
69 69
         $scope = [];
70 70
         if ($this->finance !== null) {
71 71
 		$scope[] = $this->finance->getValue().':'.self::FINANCE;
72
-		if($this->finance->getValue() == Rights::WRITE)
73
-			$scope[] = Rights::READ.':'.self::FINANCE;
72
+		if($this->finance->getValue() == Rights::WRITE) {
73
+					$scope[] = Rights::READ.':'.self::FINANCE;
74
+		}
74 75
         }
75 76
         if ($this->purchase !== null) {
76 77
 		$scope[] = $this->purchase->getValue().':'.self::PURCHASE;
77
-		if($this->purchase->getValue() == Rights::WRITE)
78
-			$scope[] = Rights::READ.':'.self::PURCHASE;
78
+		if($this->purchase->getValue() == Rights::WRITE) {
79
+					$scope[] = Rights::READ.':'.self::PURCHASE;
80
+		}
79 81
         }
80 82
         if ($this->product !== null) {
81 83
         	$scope[] = $this->product->getValue().':'.self::PRODUCT;
82
-		if($this->product->getValue() == Rights::WRITE)
83
-			$scope[] = Rights::READ.':'.self::PRODUCT;
84
+		if($this->product->getValue() == Rights::WRITE) {
85
+					$scope[] = Rights::READ.':'.self::PRODUCT;
86
+		}
84 87
         }
85 88
         if ($this->inventory !== null) {
86 89
 		$scope[] = $this->inventory->getValue().':'.self::INVENTORY;
87
-		if($this->inventory->getValue() == Rights::WRITE)
88
-			$scope[] = Rights::READ.':'.self::INVENTORY;
90
+		if($this->inventory->getValue() == Rights::WRITE) {
91
+					$scope[] = Rights::READ.':'.self::INVENTORY;
92
+		}
89 93
         }
90 94
         if ($this->image !== null) {
91 95
 		$scope[] = $this->image->getValue().':'.self::IMAGE;
92
-		if($this->image->getValue() == Rights::WRITE)
93
-			$scope[] = Rights::READ.':'.self::IMAGE;
96
+		if($this->image->getValue() == Rights::WRITE) {
97
+					$scope[] = Rights::READ.':'.self::IMAGE;
98
+		}
94 99
         }
95 100
         return implode(' ', $scope);
96 101
     }
Please login to merge, or discard this patch.