@@ -114,9 +114,9 @@ |
||
114 | 114 | 'countryCode' => $this->country_code, |
115 | 115 | ); |
116 | 116 | |
117 | - $data = array_filter( $data ); |
|
117 | + $data = array_filter($data); |
|
118 | 118 | |
119 | - if ( empty( $data ) ) { |
|
119 | + if (empty($data)) { |
|
120 | 120 | return null; |
121 | 121 | } |
122 | 122 |
@@ -26,16 +26,16 @@ |
||
26 | 26 | * @param string $post_id Post ID. |
27 | 27 | * @return Config |
28 | 28 | */ |
29 | - public function get_config( $post_id ) { |
|
29 | + public function get_config($post_id) { |
|
30 | 30 | $config = new Config(); |
31 | 31 | |
32 | 32 | $config->post_id = $post_id; |
33 | - $config->mode = get_post_meta( $post_id, '_pronamic_gateway_mode', true ); |
|
34 | - $config->refresh_token = get_post_meta( $post_id, '_pronamic_gateway_omnikassa_2_refresh_token', true ); |
|
35 | - $config->signing_key = get_post_meta( $post_id, '_pronamic_gateway_omnikassa_2_signing_key', true ); |
|
36 | - $config->access_token = get_post_meta( $post_id, '_pronamic_gateway_omnikassa_2_access_token', true ); |
|
37 | - $config->access_token_valid_until = get_post_meta( $post_id, '_pronamic_gateway_omnikassa_2_access_token_valid_until', true ); |
|
38 | - $config->order_id = get_post_meta( $post_id, '_pronamic_gateway_omnikassa_2_order_id', true ); |
|
33 | + $config->mode = get_post_meta($post_id, '_pronamic_gateway_mode', true); |
|
34 | + $config->refresh_token = get_post_meta($post_id, '_pronamic_gateway_omnikassa_2_refresh_token', true); |
|
35 | + $config->signing_key = get_post_meta($post_id, '_pronamic_gateway_omnikassa_2_signing_key', true); |
|
36 | + $config->access_token = get_post_meta($post_id, '_pronamic_gateway_omnikassa_2_access_token', true); |
|
37 | + $config->access_token_valid_until = get_post_meta($post_id, '_pronamic_gateway_omnikassa_2_access_token_valid_until', true); |
|
38 | + $config->order_id = get_post_meta($post_id, '_pronamic_gateway_omnikassa_2_order_id', true); |
|
39 | 39 | |
40 | 40 | return $config; |
41 | 41 | } |
@@ -24,8 +24,8 @@ discard block |
||
24 | 24 | * Constructs and initialize settings. |
25 | 25 | */ |
26 | 26 | public function __construct() { |
27 | - add_filter( 'pronamic_pay_gateway_sections', array( $this, 'sections' ) ); |
|
28 | - add_filter( 'pronamic_pay_gateway_fields', array( $this, 'fields' ) ); |
|
27 | + add_filter('pronamic_pay_gateway_sections', array($this, 'sections')); |
|
28 | + add_filter('pronamic_pay_gateway_fields', array($this, 'fields')); |
|
29 | 29 | } |
30 | 30 | |
31 | 31 | /** |
@@ -34,26 +34,26 @@ discard block |
||
34 | 34 | * @param array $sections Sections. |
35 | 35 | * @return array |
36 | 36 | */ |
37 | - public function sections( array $sections ) { |
|
37 | + public function sections(array $sections) { |
|
38 | 38 | $sections['omnikassa-2'] = array( |
39 | - 'title' => __( 'OmniKassa 2.0', 'pronamic_ideal' ), |
|
40 | - 'methods' => array( 'omnikassa-2' ), |
|
39 | + 'title' => __('OmniKassa 2.0', 'pronamic_ideal'), |
|
40 | + 'methods' => array('omnikassa-2'), |
|
41 | 41 | ); |
42 | 42 | |
43 | 43 | // Advanced. |
44 | 44 | $sections['omnikassa-2_advanced'] = array( |
45 | - 'title' => __( 'Advanced', 'pronamic_ideal' ), |
|
46 | - 'methods' => array( 'omnikassa-2' ), |
|
45 | + 'title' => __('Advanced', 'pronamic_ideal'), |
|
46 | + 'methods' => array('omnikassa-2'), |
|
47 | 47 | ); |
48 | 48 | |
49 | 49 | // Transaction feedback. |
50 | 50 | $sections['omnikassa-2_feedback'] = array( |
51 | - 'title' => __( 'Transaction feedback', 'pronamic_ideal' ), |
|
52 | - 'methods' => array( 'omnikassa-2' ), |
|
51 | + 'title' => __('Transaction feedback', 'pronamic_ideal'), |
|
52 | + 'methods' => array('omnikassa-2'), |
|
53 | 53 | 'description' => sprintf( |
54 | 54 | /* translators: %s: OmniKassa 2 */ |
55 | - __( 'Set the Webhook URL in the %s dashboard to receive automatic transaction status updates.', 'pronamic_ideal' ), |
|
56 | - __( 'OmniKassa 2.0', 'pronamic_ideal' ) |
|
55 | + __('Set the Webhook URL in the %s dashboard to receive automatic transaction status updates.', 'pronamic_ideal'), |
|
56 | + __('OmniKassa 2.0', 'pronamic_ideal') |
|
57 | 57 | ), |
58 | 58 | ); |
59 | 59 | |
@@ -66,15 +66,15 @@ discard block |
||
66 | 66 | * @param array $fields Fields. |
67 | 67 | * @return array |
68 | 68 | */ |
69 | - public function fields( array $fields ) { |
|
69 | + public function fields(array $fields) { |
|
70 | 70 | // Refresh Token. |
71 | 71 | $fields[] = array( |
72 | 72 | 'filter' => FILTER_SANITIZE_STRING, |
73 | 73 | 'section' => 'omnikassa-2', |
74 | 74 | 'meta_key' => '_pronamic_gateway_omnikassa_2_refresh_token', |
75 | - 'title' => _x( 'Refresh Token', 'omnikassa', 'pronamic_ideal' ), |
|
75 | + 'title' => _x('Refresh Token', 'omnikassa', 'pronamic_ideal'), |
|
76 | 76 | 'type' => 'textarea', |
77 | - 'classes' => array( 'code' ), |
|
77 | + 'classes' => array('code'), |
|
78 | 78 | ); |
79 | 79 | |
80 | 80 | // Signing Key. |
@@ -82,19 +82,19 @@ discard block |
||
82 | 82 | 'filter' => FILTER_SANITIZE_STRING, |
83 | 83 | 'section' => 'omnikassa-2', |
84 | 84 | 'meta_key' => '_pronamic_gateway_omnikassa_2_signing_key', |
85 | - 'title' => _x( 'Signing Key', 'omnikassa', 'pronamic_ideal' ), |
|
85 | + 'title' => _x('Signing Key', 'omnikassa', 'pronamic_ideal'), |
|
86 | 86 | 'type' => 'text', |
87 | - 'classes' => array( 'large-text', 'code' ), |
|
87 | + 'classes' => array('large-text', 'code'), |
|
88 | 88 | ); |
89 | 89 | |
90 | 90 | // Transaction feedback. |
91 | 91 | $fields[] = array( |
92 | 92 | 'section' => 'omnikassa-2', |
93 | - 'title' => __( 'Transaction feedback', 'pronamic_ideal' ), |
|
93 | + 'title' => __('Transaction feedback', 'pronamic_ideal'), |
|
94 | 94 | 'type' => 'description', |
95 | 95 | 'html' => sprintf( |
96 | 96 | '<span class="dashicons dashicons-warning"></span> %s', |
97 | - __( 'Receiving payment status updates needs additional configuration, if not yet completed.', 'pronamic_ideal' ) |
|
97 | + __('Receiving payment status updates needs additional configuration, if not yet completed.', 'pronamic_ideal') |
|
98 | 98 | ), |
99 | 99 | ); |
100 | 100 | |
@@ -103,17 +103,17 @@ discard block |
||
103 | 103 | 'filter' => FILTER_SANITIZE_STRING, |
104 | 104 | 'section' => 'omnikassa-2_advanced', |
105 | 105 | 'meta_key' => '_pronamic_gateway_omnikassa_2_order_id', |
106 | - 'title' => __( 'Order ID', 'pronamic_ideal' ), |
|
106 | + 'title' => __('Order ID', 'pronamic_ideal'), |
|
107 | 107 | 'type' => 'text', |
108 | - 'classes' => array( 'regular-text', 'code' ), |
|
108 | + 'classes' => array('regular-text', 'code'), |
|
109 | 109 | 'tooltip' => sprintf( |
110 | 110 | /* translators: %s: Parameter */ |
111 | - __( 'The OmniKassa %s parameter.', 'pronamic_ideal' ), |
|
112 | - sprintf( '<code>%s</code>', 'orderId' ) |
|
111 | + __('The OmniKassa %s parameter.', 'pronamic_ideal'), |
|
112 | + sprintf('<code>%s</code>', 'orderId') |
|
113 | 113 | ), |
114 | 114 | 'description' => sprintf( |
115 | 115 | '%s %s<br />%s', |
116 | - __( 'Available tags:', 'pronamic_ideal' ), |
|
116 | + __('Available tags:', 'pronamic_ideal'), |
|
117 | 117 | sprintf( |
118 | 118 | '<code>%s</code> <code>%s</code>', |
119 | 119 | '{order_id}', |
@@ -121,7 +121,7 @@ discard block |
||
121 | 121 | ), |
122 | 122 | sprintf( |
123 | 123 | /* translators: %s: {payment_id} */ |
124 | - __( 'Default: <code>%s</code>', 'pronamic_ideal' ), |
|
124 | + __('Default: <code>%s</code>', 'pronamic_ideal'), |
|
125 | 125 | '{payment_id}' |
126 | 126 | ) |
127 | 127 | ), |
@@ -130,13 +130,13 @@ discard block |
||
130 | 130 | // Webhook. |
131 | 131 | $fields[] = array( |
132 | 132 | 'section' => 'omnikassa-2_feedback', |
133 | - 'title' => __( 'Webhook URL', 'pronamic_ideal' ), |
|
133 | + 'title' => __('Webhook URL', 'pronamic_ideal'), |
|
134 | 134 | 'type' => 'text', |
135 | - 'classes' => array( 'large-text', 'code' ), |
|
136 | - 'value' => add_query_arg( 'omnikassa2_webhook', '', home_url( '/' ) ), |
|
135 | + 'classes' => array('large-text', 'code'), |
|
136 | + 'value' => add_query_arg('omnikassa2_webhook', '', home_url('/')), |
|
137 | 137 | 'readonly' => true, |
138 | - 'methods' => array( 'omnikassa-2' ), |
|
139 | - 'tooltip' => __( 'The Webhook URL as sent with each transaction to receive automatic payment status updates on.', 'pronamic_ideal' ), |
|
138 | + 'methods' => array('omnikassa-2'), |
|
139 | + 'tooltip' => __('The Webhook URL as sent with each transaction to receive automatic payment status updates on.', 'pronamic_ideal'), |
|
140 | 140 | ); |
141 | 141 | |
142 | 142 | return $fields; |
@@ -151,8 +151,8 @@ discard block |
||
151 | 151 | * @param Money $amount Amount. |
152 | 152 | * @param string $merchant_return_url Merchant return URL. |
153 | 153 | */ |
154 | - public function __construct( $merchant_order_id, $amount, $merchant_return_url ) { |
|
155 | - $this->timestamp = date( DATE_ATOM ); |
|
154 | + public function __construct($merchant_order_id, $amount, $merchant_return_url) { |
|
155 | + $this->timestamp = date(DATE_ATOM); |
|
156 | 156 | $this->merchant_order_id = $merchant_order_id; |
157 | 157 | $this->amount = $amount; |
158 | 158 | $this->merchant_return_url = $merchant_return_url; |
@@ -163,7 +163,7 @@ discard block |
||
163 | 163 | * |
164 | 164 | * @param string $description Description. |
165 | 165 | */ |
166 | - public function set_description( $description ) { |
|
166 | + public function set_description($description) { |
|
167 | 167 | $this->description = $description; |
168 | 168 | } |
169 | 169 | |
@@ -172,7 +172,7 @@ discard block |
||
172 | 172 | * |
173 | 173 | * @param string $language Language. |
174 | 174 | */ |
175 | - public function set_language( $language ) { |
|
175 | + public function set_language($language) { |
|
176 | 176 | $this->language = $language; |
177 | 177 | } |
178 | 178 | |
@@ -181,7 +181,7 @@ discard block |
||
181 | 181 | * |
182 | 182 | * @param string $payment_brand Payment brand. |
183 | 183 | */ |
184 | - public function set_payment_brand( $payment_brand ) { |
|
184 | + public function set_payment_brand($payment_brand) { |
|
185 | 185 | $this->payment_brand = $payment_brand; |
186 | 186 | } |
187 | 187 | |
@@ -190,7 +190,7 @@ discard block |
||
190 | 190 | * |
191 | 191 | * @param string $payment_brand_force Payment brand force. |
192 | 192 | */ |
193 | - public function set_payment_brand_force( $payment_brand_force ) { |
|
193 | + public function set_payment_brand_force($payment_brand_force) { |
|
194 | 194 | $this->payment_brand_force = $payment_brand_force; |
195 | 195 | } |
196 | 196 | |
@@ -237,8 +237,8 @@ discard block |
||
237 | 237 | ); |
238 | 238 | |
239 | 239 | // Remove empty optional fields. |
240 | - $optional = array_filter( $optional ); |
|
240 | + $optional = array_filter($optional); |
|
241 | 241 | |
242 | - return array_merge( $fields, $optional ); |
|
242 | + return array_merge($fields, $optional); |
|
243 | 243 | } |
244 | 244 | } |
@@ -64,7 +64,7 @@ discard block |
||
64 | 64 | * |
65 | 65 | * @param string $email_address E-mailadress of the consumer. |
66 | 66 | */ |
67 | - public function set_email_address( $email_address ) { |
|
67 | + public function set_email_address($email_address) { |
|
68 | 68 | $this->email_address = $email_address; |
69 | 69 | } |
70 | 70 | |
@@ -82,9 +82,9 @@ discard block |
||
82 | 82 | 'telephoneNumber' => $this->telephoneNumber, |
83 | 83 | ); |
84 | 84 | |
85 | - $data = array_filter( $data ); |
|
85 | + $data = array_filter($data); |
|
86 | 86 | |
87 | - if ( empty( $data ) ) { |
|
87 | + if (empty($data)) { |
|
88 | 88 | return null; |
89 | 89 | } |
90 | 90 |
@@ -54,8 +54,8 @@ |
||
54 | 54 | * @param string $status OmniKassa 2.0 status. |
55 | 55 | * @return string|null |
56 | 56 | */ |
57 | - public static function transform( $status ) { |
|
58 | - switch ( $status ) { |
|
57 | + public static function transform($status) { |
|
58 | + switch ($status) { |
|
59 | 59 | case self::CANCELLED: |
60 | 60 | return Core_Statuses::CANCELLED; |
61 | 61 | case self::COMPLETED: |
@@ -25,21 +25,21 @@ discard block |
||
25 | 25 | * @param string $signing_key Signing Key. |
26 | 26 | * @return string|null |
27 | 27 | */ |
28 | - public static function get_signature( Signable $signable, $signing_key ) { |
|
28 | + public static function get_signature(Signable $signable, $signing_key) { |
|
29 | 29 | $data = $signable->get_signature_data(); |
30 | 30 | |
31 | - if ( empty( $data ) ) { |
|
31 | + if (empty($data)) { |
|
32 | 32 | return; |
33 | 33 | } |
34 | 34 | |
35 | - if ( empty( $signing_key ) ) { |
|
35 | + if (empty($signing_key)) { |
|
36 | 36 | return; |
37 | 37 | } |
38 | 38 | |
39 | 39 | $signature = hash_hmac( |
40 | 40 | 'sha512', |
41 | - implode( ',', $data ), |
|
42 | - base64_decode( $signing_key ) |
|
41 | + implode(',', $data), |
|
42 | + base64_decode($signing_key) |
|
43 | 43 | ); |
44 | 44 | |
45 | 45 | return $signature; |
@@ -52,12 +52,12 @@ discard block |
||
52 | 52 | * @param string $signature_b Signature B. |
53 | 53 | * @return bool True if valid, false otherwise. |
54 | 54 | */ |
55 | - public static function validate_signature( $signature_a, $signature_b ) { |
|
56 | - if ( empty( $signature_a ) || empty( $signature_b ) ) { |
|
55 | + public static function validate_signature($signature_a, $signature_b) { |
|
56 | + if (empty($signature_a) || empty($signature_b)) { |
|
57 | 57 | // Empty signature string or null from calculation. |
58 | 58 | return false; |
59 | 59 | } |
60 | 60 | |
61 | - return ( 0 === strcasecmp( $signature_a, $signature_b ) ); |
|
61 | + return (0 === strcasecmp($signature_a, $signature_b)); |
|
62 | 62 | } |
63 | 63 | } |
@@ -71,7 +71,7 @@ discard block |
||
71 | 71 | * |
72 | 72 | * @param string $url URL. |
73 | 73 | */ |
74 | - public function set_url( $url ) { |
|
74 | + public function set_url($url) { |
|
75 | 75 | $this->url = $url; |
76 | 76 | } |
77 | 77 | |
@@ -89,7 +89,7 @@ discard block |
||
89 | 89 | * |
90 | 90 | * @param string $refresh_token Refresh token. |
91 | 91 | */ |
92 | - public function set_refresh_token( $refresh_token ) { |
|
92 | + public function set_refresh_token($refresh_token) { |
|
93 | 93 | $this->refresh_token = $refresh_token; |
94 | 94 | } |
95 | 95 | |
@@ -107,7 +107,7 @@ discard block |
||
107 | 107 | * |
108 | 108 | * @param string $signing_key Signing key. |
109 | 109 | */ |
110 | - public function set_signing_key( $signing_key ) { |
|
110 | + public function set_signing_key($signing_key) { |
|
111 | 111 | $this->signing_key = $signing_key; |
112 | 112 | } |
113 | 113 | |
@@ -119,7 +119,7 @@ discard block |
||
119 | 119 | * @param string $token Authorization token. |
120 | 120 | * @param object|null $object Object. |
121 | 121 | */ |
122 | - private function request( $method, $endpoint, $token, $object = null ) { |
|
122 | + private function request($method, $endpoint, $token, $object = null) { |
|
123 | 123 | // URL. |
124 | 124 | $url = $this->get_url() . $endpoint; |
125 | 125 | |
@@ -131,45 +131,45 @@ discard block |
||
131 | 131 | ), |
132 | 132 | ); |
133 | 133 | |
134 | - if ( null !== $object ) { |
|
134 | + if (null !== $object) { |
|
135 | 135 | $args['headers']['Content-Type'] = 'application/json'; |
136 | 136 | |
137 | - $args['body'] = wp_json_encode( $object ); |
|
137 | + $args['body'] = wp_json_encode($object); |
|
138 | 138 | } |
139 | 139 | |
140 | 140 | // Request. |
141 | - $response = wp_remote_request( $url, $args ); |
|
141 | + $response = wp_remote_request($url, $args); |
|
142 | 142 | |
143 | - if ( is_wp_error( $response ) ) { |
|
143 | + if (is_wp_error($response)) { |
|
144 | 144 | $this->error = $response; |
145 | 145 | |
146 | - $this->error->add( 'omnikassa_2_error', 'HTTP Request Failed' ); |
|
146 | + $this->error->add('omnikassa_2_error', 'HTTP Request Failed'); |
|
147 | 147 | |
148 | 148 | return false; |
149 | 149 | } |
150 | 150 | |
151 | 151 | // Body. |
152 | - $body = wp_remote_retrieve_body( $response ); |
|
152 | + $body = wp_remote_retrieve_body($response); |
|
153 | 153 | |
154 | - $data = json_decode( $body ); |
|
154 | + $data = json_decode($body); |
|
155 | 155 | |
156 | - if ( ! is_object( $data ) ) { |
|
157 | - $this->error = new \WP_Error( 'omnikassa_2_error', 'Could not parse response.', $data ); |
|
156 | + if ( ! is_object($data)) { |
|
157 | + $this->error = new \WP_Error('omnikassa_2_error', 'Could not parse response.', $data); |
|
158 | 158 | |
159 | 159 | return false; |
160 | 160 | } |
161 | 161 | |
162 | 162 | // Error. |
163 | - if ( isset( $data->errorCode ) ) { |
|
163 | + if (isset($data->errorCode)) { |
|
164 | 164 | $message = 'Unknown error.'; |
165 | 165 | |
166 | - if ( isset( $data->consumerMessage ) ) { |
|
166 | + if (isset($data->consumerMessage)) { |
|
167 | 167 | $message = $data->consumerMessage; |
168 | - } elseif ( isset( $data->errorMessage ) ) { |
|
168 | + } elseif (isset($data->errorMessage)) { |
|
169 | 169 | $message = $data->errorMessage; |
170 | 170 | } |
171 | 171 | |
172 | - $this->error = new \WP_Error( 'omnikassa_2_error', $message, $data ); |
|
172 | + $this->error = new \WP_Error('omnikassa_2_error', $message, $data); |
|
173 | 173 | |
174 | 174 | return false; |
175 | 175 | } |
@@ -184,7 +184,7 @@ discard block |
||
184 | 184 | * @return string |
185 | 185 | */ |
186 | 186 | public function get_access_token_data() { |
187 | - return $this->request( 'GET', 'gatekeeper/refresh', $this->get_refresh_token() ); |
|
187 | + return $this->request('GET', 'gatekeeper/refresh', $this->get_refresh_token()); |
|
188 | 188 | } |
189 | 189 | |
190 | 190 | /** |
@@ -194,12 +194,12 @@ discard block |
||
194 | 194 | * @param Order $order Order. |
195 | 195 | * @return object|bool |
196 | 196 | */ |
197 | - public function order_announce( $config, Order $order ) { |
|
197 | + public function order_announce($config, Order $order) { |
|
198 | 198 | $object = $order->get_json(); |
199 | 199 | |
200 | - $object->signature = Security::get_signature( $order, $config->signing_key ); |
|
200 | + $object->signature = Security::get_signature($order, $config->signing_key); |
|
201 | 201 | |
202 | - return $this->request( 'POST', 'order/server/api/order', $config->access_token, $object ); |
|
202 | + return $this->request('POST', 'order/server/api/order', $config->access_token, $object); |
|
203 | 203 | } |
204 | 204 | |
205 | 205 | /** |
@@ -208,9 +208,9 @@ discard block |
||
208 | 208 | * @param string $notification_token Notification token. |
209 | 209 | * @return OrderResults |
210 | 210 | */ |
211 | - public function get_order_results( $notification_token ) { |
|
212 | - $result = $this->request( 'GET', 'order/server/api/events/results/merchant.order.status.changed', $notification_token ); |
|
211 | + public function get_order_results($notification_token) { |
|
212 | + $result = $this->request('GET', 'order/server/api/events/results/merchant.order.status.changed', $notification_token); |
|
213 | 213 | |
214 | - return OrderResults::from_object( $result ); |
|
214 | + return OrderResults::from_object($result); |
|
215 | 215 | } |
216 | 216 | } |
@@ -61,8 +61,8 @@ discard block |
||
61 | 61 | * @param int|string $poi_id POI ID. |
62 | 62 | * @param string $signature Signature. |
63 | 63 | */ |
64 | - public function __construct( $authentication, $expiry, $event_name, $poi_id, $signature ) { |
|
65 | - parent::__construct( $signature ); |
|
64 | + public function __construct($authentication, $expiry, $event_name, $poi_id, $signature) { |
|
65 | + parent::__construct($signature); |
|
66 | 66 | |
67 | 67 | $this->authentication = $authentication; |
68 | 68 | $this->expiry = $expiry; |
@@ -94,9 +94,9 @@ discard block |
||
94 | 94 | * @return bool True if notice authentication token is epxired, false otherwise. |
95 | 95 | */ |
96 | 96 | public function is_expired() { |
97 | - $timestamp = strtotime( $this->get_expiry() ); |
|
97 | + $timestamp = strtotime($this->get_expiry()); |
|
98 | 98 | |
99 | - if ( false === $timestamp ) { |
|
99 | + if (false === $timestamp) { |
|
100 | 100 | return true; |
101 | 101 | } |
102 | 102 | |
@@ -142,25 +142,25 @@ discard block |
||
142 | 142 | * @return Notification |
143 | 143 | * @throws InvalidArgumentException Throws invalid argument exception when object does not contains the required properties. |
144 | 144 | */ |
145 | - public static function from_object( stdClass $object ) { |
|
146 | - if ( ! isset( $object->signature ) ) { |
|
147 | - throw new InvalidArgumentException( 'Object must contain `signature` property.' ); |
|
145 | + public static function from_object(stdClass $object) { |
|
146 | + if ( ! isset($object->signature)) { |
|
147 | + throw new InvalidArgumentException('Object must contain `signature` property.'); |
|
148 | 148 | } |
149 | 149 | |
150 | - if ( ! isset( $object->authentication ) ) { |
|
151 | - throw new InvalidArgumentException( 'Object must contain `authentication` property.' ); |
|
150 | + if ( ! isset($object->authentication)) { |
|
151 | + throw new InvalidArgumentException('Object must contain `authentication` property.'); |
|
152 | 152 | } |
153 | 153 | |
154 | - if ( ! isset( $object->expiry ) ) { |
|
155 | - throw new InvalidArgumentException( 'Object must contain `expiry` property.' ); |
|
154 | + if ( ! isset($object->expiry)) { |
|
155 | + throw new InvalidArgumentException('Object must contain `expiry` property.'); |
|
156 | 156 | } |
157 | 157 | |
158 | - if ( ! isset( $object->eventName ) ) { |
|
159 | - throw new InvalidArgumentException( 'Object must contain `eventName` property.' ); |
|
158 | + if ( ! isset($object->eventName)) { |
|
159 | + throw new InvalidArgumentException('Object must contain `eventName` property.'); |
|
160 | 160 | } |
161 | 161 | |
162 | - if ( ! isset( $object->poiId ) ) { |
|
163 | - throw new InvalidArgumentException( 'Object must contain `poiId` property.' ); |
|
162 | + if ( ! isset($object->poiId)) { |
|
163 | + throw new InvalidArgumentException('Object must contain `poiId` property.'); |
|
164 | 164 | } |
165 | 165 | |
166 | 166 | return new self( |
@@ -179,15 +179,15 @@ discard block |
||
179 | 179 | * @return Notification |
180 | 180 | * @throws \JsonSchema\Exception\ValidationException Throws JSON schema validation exception when JSON is invalid. |
181 | 181 | */ |
182 | - public static function from_json( $json ) { |
|
183 | - $data = json_decode( $json ); |
|
182 | + public static function from_json($json) { |
|
183 | + $data = json_decode($json); |
|
184 | 184 | |
185 | 185 | $validator = new Validator(); |
186 | 186 | |
187 | - $validator->validate( $data, (object) array( |
|
188 | - '$ref' => 'file://' . realpath( __DIR__ . '/../json-schemas/notification.json' ), |
|
189 | - ), Constraint::CHECK_MODE_EXCEPTIONS ); |
|
187 | + $validator->validate($data, (object) array( |
|
188 | + '$ref' => 'file://' . realpath(__DIR__ . '/../json-schemas/notification.json'), |
|
189 | + ), Constraint::CHECK_MODE_EXCEPTIONS); |
|
190 | 190 | |
191 | - return self::from_object( $data ); |
|
191 | + return self::from_object($data); |
|
192 | 192 | } |
193 | 193 | } |