@@ -44,8 +44,8 @@ discard block |
||
| 44 | 44 | * @param string $status Status. |
| 45 | 45 | * @param string $signature Signature. |
| 46 | 46 | */ |
| 47 | - public function __construct( $order_id, $status, $signature ) { |
|
| 48 | - parent::__construct( $signature ); |
|
| 47 | + public function __construct($order_id, $status, $signature) { |
|
| 48 | + parent::__construct($signature); |
|
| 49 | 49 | |
| 50 | 50 | $this->order_id = $order_id; |
| 51 | 51 | $this->status = $status; |
@@ -89,13 +89,13 @@ discard block |
||
| 89 | 89 | * @param array $data Data array. |
| 90 | 90 | * @return bool True if array contains return parameters, false otherwise. |
| 91 | 91 | */ |
| 92 | - public static function contains( array $data ) { |
|
| 92 | + public static function contains(array $data) { |
|
| 93 | 93 | return ( |
| 94 | - array_key_exists( 'order_id', $data ) |
|
| 94 | + array_key_exists('order_id', $data) |
|
| 95 | 95 | && |
| 96 | - array_key_exists( 'status', $data ) |
|
| 96 | + array_key_exists('status', $data) |
|
| 97 | 97 | && |
| 98 | - array_key_exists( 'signature', $data ) |
|
| 98 | + array_key_exists('signature', $data) |
|
| 99 | 99 | ); |
| 100 | 100 | } |
| 101 | 101 | |
@@ -106,17 +106,17 @@ discard block |
||
| 106 | 106 | * @return ReturnParameters |
| 107 | 107 | * @throws InvalidArgumentException Throws invalid argument exception when array does not contains the required keys. |
| 108 | 108 | */ |
| 109 | - public static function from_array( array $data ) { |
|
| 110 | - if ( ! array_key_exists( 'order_id', $data ) ) { |
|
| 111 | - throw new InvalidArgumentException( 'Data array must contain `order_id` field.' ); |
|
| 109 | + public static function from_array(array $data) { |
|
| 110 | + if ( ! array_key_exists('order_id', $data)) { |
|
| 111 | + throw new InvalidArgumentException('Data array must contain `order_id` field.'); |
|
| 112 | 112 | } |
| 113 | 113 | |
| 114 | - if ( ! array_key_exists( 'status', $data ) ) { |
|
| 115 | - throw new InvalidArgumentException( 'Data array must contain `status` field.' ); |
|
| 114 | + if ( ! array_key_exists('status', $data)) { |
|
| 115 | + throw new InvalidArgumentException('Data array must contain `status` field.'); |
|
| 116 | 116 | } |
| 117 | 117 | |
| 118 | - if ( ! array_key_exists( 'signature', $data ) ) { |
|
| 119 | - throw new InvalidArgumentException( 'Data array must contain `signature` field.' ); |
|
| 118 | + if ( ! array_key_exists('signature', $data)) { |
|
| 119 | + throw new InvalidArgumentException('Data array must contain `signature` field.'); |
|
| 120 | 120 | } |
| 121 | 121 | |
| 122 | 122 | return new self( |
@@ -23,7 +23,7 @@ |
||
| 23 | 23 | * |
| 24 | 24 | * @param string $signature Signature. |
| 25 | 25 | */ |
| 26 | - public function __construct( $signature ) { |
|
| 27 | - $this->set_signature( $signature ); |
|
| 26 | + public function __construct($signature) { |
|
| 27 | + $this->set_signature($signature); |
|
| 28 | 28 | } |
| 29 | 29 | } |
@@ -61,10 +61,10 @@ |
||
| 61 | 61 | * @return bool True if valid, false otherwise. |
| 62 | 62 | */ |
| 63 | 63 | public function is_access_token_valid() { |
| 64 | - if ( empty( $this->access_token ) ) { |
|
| 64 | + if (empty($this->access_token)) { |
|
| 65 | 65 | return false; |
| 66 | 66 | } |
| 67 | 67 | |
| 68 | - return strtotime( $this->access_token_valid_until ) > time(); |
|
| 68 | + return strtotime($this->access_token_valid_until) > time(); |
|
| 69 | 69 | } |
| 70 | 70 | } |
@@ -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; |
@@ -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,17 +25,17 @@ discard block |
||
| 25 | 25 | * Listen to OmniKassa 2.0 webhook requests. |
| 26 | 26 | */ |
| 27 | 27 | public static function listen() { |
| 28 | - if ( ! filter_has_var( INPUT_GET, 'omnikassa2_webhook' ) ) { |
|
| 28 | + if ( ! filter_has_var(INPUT_GET, 'omnikassa2_webhook')) { |
|
| 29 | 29 | return; |
| 30 | 30 | } |
| 31 | 31 | |
| 32 | - $json = file_get_contents( 'php://input' ); |
|
| 32 | + $json = file_get_contents('php://input'); |
|
| 33 | 33 | |
| 34 | - if ( false === $json ) { |
|
| 34 | + if (false === $json) { |
|
| 35 | 35 | return; |
| 36 | 36 | } |
| 37 | 37 | |
| 38 | - $notification = Notification::from_json( $json ); |
|
| 38 | + $notification = Notification::from_json($json); |
|
| 39 | 39 | |
| 40 | 40 | $query = new \WP_Query( |
| 41 | 41 | array( |
@@ -51,11 +51,11 @@ discard block |
||
| 51 | 51 | ) |
| 52 | 52 | ); |
| 53 | 53 | |
| 54 | - foreach ( $query->posts as $post ) { |
|
| 55 | - $gateway = Plugin::get_gateway( $post->ID ); |
|
| 54 | + foreach ($query->posts as $post) { |
|
| 55 | + $gateway = Plugin::get_gateway($post->ID); |
|
| 56 | 56 | |
| 57 | - if ( $gateway instanceof Gateway ) { |
|
| 58 | - $gateway->handle_notification( $notification ); |
|
| 57 | + if ($gateway instanceof Gateway) { |
|
| 58 | + $gateway->handle_notification($notification); |
|
| 59 | 59 | } |
| 60 | 60 | } |
| 61 | 61 | } |
@@ -95,7 +95,7 @@ discard block |
||
| 95 | 95 | * @param Money $paid_amount Paid amount. |
| 96 | 96 | * @param Money $total_amount Total amount. |
| 97 | 97 | */ |
| 98 | - public function __construct( $merchant_order_id, $omnikassa_order_id, $poi_id, $order_status, $order_status_datetime, $error_code, Money $paid_amount, Money $total_amount ) { |
|
| 98 | + public function __construct($merchant_order_id, $omnikassa_order_id, $poi_id, $order_status, $order_status_datetime, $error_code, Money $paid_amount, Money $total_amount) { |
|
| 99 | 99 | $this->merchant_order_id = $merchant_order_id; |
| 100 | 100 | $this->omnikassa_order_id = $omnikassa_order_id; |
| 101 | 101 | $this->poi_id = $poi_id; |
@@ -203,37 +203,37 @@ discard block |
||
| 203 | 203 | * @return OrderResult |
| 204 | 204 | * @throws InvalidArgumentException Throws invalid argument exception when object does not contains the required properties. |
| 205 | 205 | */ |
| 206 | - public static function from_object( stdClass $object ) { |
|
| 207 | - if ( ! isset( $object->merchantOrderId ) ) { |
|
| 208 | - throw new InvalidArgumentException( 'Object must contain `merchantOrderId` property.' ); |
|
| 206 | + public static function from_object(stdClass $object) { |
|
| 207 | + if ( ! isset($object->merchantOrderId)) { |
|
| 208 | + throw new InvalidArgumentException('Object must contain `merchantOrderId` property.'); |
|
| 209 | 209 | } |
| 210 | 210 | |
| 211 | - if ( ! isset( $object->omnikassaOrderId ) ) { |
|
| 212 | - throw new InvalidArgumentException( 'Object must contain `omnikassaOrderId` property.' ); |
|
| 211 | + if ( ! isset($object->omnikassaOrderId)) { |
|
| 212 | + throw new InvalidArgumentException('Object must contain `omnikassaOrderId` property.'); |
|
| 213 | 213 | } |
| 214 | 214 | |
| 215 | - if ( ! isset( $object->poiId ) ) { |
|
| 216 | - throw new InvalidArgumentException( 'Object must contain `poiId` property.' ); |
|
| 215 | + if ( ! isset($object->poiId)) { |
|
| 216 | + throw new InvalidArgumentException('Object must contain `poiId` property.'); |
|
| 217 | 217 | } |
| 218 | 218 | |
| 219 | - if ( ! isset( $object->orderStatus ) ) { |
|
| 220 | - throw new InvalidArgumentException( 'Object must contain `orderStatus` property.' ); |
|
| 219 | + if ( ! isset($object->orderStatus)) { |
|
| 220 | + throw new InvalidArgumentException('Object must contain `orderStatus` property.'); |
|
| 221 | 221 | } |
| 222 | 222 | |
| 223 | - if ( ! isset( $object->orderStatusDateTime ) ) { |
|
| 224 | - throw new InvalidArgumentException( 'Object must contain `orderStatusDateTime` property.' ); |
|
| 223 | + if ( ! isset($object->orderStatusDateTime)) { |
|
| 224 | + throw new InvalidArgumentException('Object must contain `orderStatusDateTime` property.'); |
|
| 225 | 225 | } |
| 226 | 226 | |
| 227 | - if ( ! isset( $object->errorCode ) ) { |
|
| 228 | - throw new InvalidArgumentException( 'Object must contain `errorCode` property.' ); |
|
| 227 | + if ( ! isset($object->errorCode)) { |
|
| 228 | + throw new InvalidArgumentException('Object must contain `errorCode` property.'); |
|
| 229 | 229 | } |
| 230 | 230 | |
| 231 | - if ( ! isset( $object->paidAmount ) ) { |
|
| 232 | - throw new InvalidArgumentException( 'Object must contain `paidAmount` property.' ); |
|
| 231 | + if ( ! isset($object->paidAmount)) { |
|
| 232 | + throw new InvalidArgumentException('Object must contain `paidAmount` property.'); |
|
| 233 | 233 | } |
| 234 | 234 | |
| 235 | - if ( ! isset( $object->totalAmount ) ) { |
|
| 236 | - throw new InvalidArgumentException( 'Object must contain `totalAmount` property.' ); |
|
| 235 | + if ( ! isset($object->totalAmount)) { |
|
| 236 | + throw new InvalidArgumentException('Object must contain `totalAmount` property.'); |
|
| 237 | 237 | } |
| 238 | 238 | |
| 239 | 239 | return new self( |
@@ -243,8 +243,8 @@ discard block |
||
| 243 | 243 | $object->orderStatus, |
| 244 | 244 | $object->orderStatusDateTime, |
| 245 | 245 | $object->errorCode, |
| 246 | - Money::from_object( $object->paidAmount ), |
|
| 247 | - Money::from_object( $object->totalAmount ) |
|
| 246 | + Money::from_object($object->paidAmount), |
|
| 247 | + Money::from_object($object->totalAmount) |
|
| 248 | 248 | ); |
| 249 | 249 | } |
| 250 | 250 | |
@@ -255,19 +255,19 @@ discard block |
||
| 255 | 255 | * @return OrderResult |
| 256 | 256 | * @throws \JsonSchema\Exception\ValidationException Throws JSON schema validation exception when JSON is invalid. |
| 257 | 257 | */ |
| 258 | - public static function from_json( $json ) { |
|
| 259 | - $data = json_decode( $json ); |
|
| 258 | + public static function from_json($json) { |
|
| 259 | + $data = json_decode($json); |
|
| 260 | 260 | |
| 261 | 261 | $validator = new Validator(); |
| 262 | 262 | |
| 263 | 263 | $validator->validate( |
| 264 | 264 | $data, |
| 265 | 265 | (object) array( |
| 266 | - '$ref' => 'file://' . realpath( __DIR__ . '/../json-schemas/json-schema-order-result.json' ), |
|
| 266 | + '$ref' => 'file://' . realpath(__DIR__ . '/../json-schemas/json-schema-order-result.json'), |
|
| 267 | 267 | ), |
| 268 | 268 | Constraint::CHECK_MODE_EXCEPTIONS |
| 269 | 269 | ); |
| 270 | 270 | |
| 271 | - return self::from_object( $data ); |
|
| 271 | + return self::from_object($data); |
|
| 272 | 272 | } |
| 273 | 273 | } |
@@ -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,19 +179,19 @@ 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 | 187 | $validator->validate( |
| 188 | 188 | $data, |
| 189 | 189 | (object) array( |
| 190 | - '$ref' => 'file://' . realpath( __DIR__ . '/../json-schemas/notification.json' ), |
|
| 190 | + '$ref' => 'file://' . realpath(__DIR__ . '/../json-schemas/notification.json'), |
|
| 191 | 191 | ), |
| 192 | 192 | Constraint::CHECK_MODE_EXCEPTIONS |
| 193 | 193 | ); |
| 194 | 194 | |
| 195 | - return self::from_object( $data ); |
|
| 195 | + return self::from_object($data); |
|
| 196 | 196 | } |
| 197 | 197 | } |
@@ -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 | - $config->post_id = intval( $post_id ); |
|
| 33 | - $config->mode = $this->get_meta( $post_id, 'mode' ); |
|
| 34 | - $config->refresh_token = $this->get_meta( $post_id, 'omnikassa_2_refresh_token' ); |
|
| 35 | - $config->signing_key = $this->get_meta( $post_id, 'omnikassa_2_signing_key' ); |
|
| 36 | - $config->access_token = $this->get_meta( $post_id, 'omnikassa_2_access_token' ); |
|
| 37 | - $config->access_token_valid_until = $this->get_meta( $post_id, 'omnikassa_2_access_token_valid_until' ); |
|
| 38 | - $config->order_id = $this->get_meta( $post_id, 'omnikassa_2_order_id' ); |
|
| 32 | + $config->post_id = intval($post_id); |
|
| 33 | + $config->mode = $this->get_meta($post_id, 'mode'); |
|
| 34 | + $config->refresh_token = $this->get_meta($post_id, 'omnikassa_2_refresh_token'); |
|
| 35 | + $config->signing_key = $this->get_meta($post_id, 'omnikassa_2_signing_key'); |
|
| 36 | + $config->access_token = $this->get_meta($post_id, 'omnikassa_2_access_token'); |
|
| 37 | + $config->access_token_valid_until = $this->get_meta($post_id, 'omnikassa_2_access_token_valid_until'); |
|
| 38 | + $config->order_id = $this->get_meta($post_id, 'omnikassa_2_order_id'); |
|
| 39 | 39 | |
| 40 | 40 | return $config; |
| 41 | 41 | } |