@@ -30,10 +30,10 @@ discard block |
||
| 30 | 30 | * |
| 31 | 31 | * @param array $items Order items. |
| 32 | 32 | */ |
| 33 | - public function __construct( $items = null ) { |
|
| 34 | - if ( is_array( $items ) ) { |
|
| 35 | - foreach ( $items as $item ) { |
|
| 36 | - $this->add_item( $item ); |
|
| 33 | + public function __construct($items = null) { |
|
| 34 | + if (is_array($items)) { |
|
| 35 | + foreach ($items as $item) { |
|
| 36 | + $this->add_item($item); |
|
| 37 | 37 | } |
| 38 | 38 | } |
| 39 | 39 | } |
@@ -47,10 +47,10 @@ discard block |
||
| 47 | 47 | * @param string $category Category. |
| 48 | 48 | * @return OrderItem |
| 49 | 49 | */ |
| 50 | - public function new_item( $name, $quantity, Money $amount, $category ) { |
|
| 51 | - $item = new OrderItem( $name, $quantity, $amount, $category ); |
|
| 50 | + public function new_item($name, $quantity, Money $amount, $category) { |
|
| 51 | + $item = new OrderItem($name, $quantity, $amount, $category); |
|
| 52 | 52 | |
| 53 | - $this->add_item( $item ); |
|
| 53 | + $this->add_item($item); |
|
| 54 | 54 | |
| 55 | 55 | return $item; |
| 56 | 56 | } |
@@ -60,7 +60,7 @@ discard block |
||
| 60 | 60 | * |
| 61 | 61 | * @param OrderItem $item Order item. |
| 62 | 62 | */ |
| 63 | - public function add_item( OrderItem $item ) { |
|
| 63 | + public function add_item(OrderItem $item) { |
|
| 64 | 64 | $this->order_items[] = $item; |
| 65 | 65 | } |
| 66 | 66 | |
@@ -80,7 +80,7 @@ discard block |
||
| 80 | 80 | */ |
| 81 | 81 | public function get_json() { |
| 82 | 82 | $data = array_map( |
| 83 | - function( $item ) { |
|
| 83 | + function($item) { |
|
| 84 | 84 | return $item->get_json(); |
| 85 | 85 | }, |
| 86 | 86 | $this->get_order_items() |
@@ -95,9 +95,9 @@ discard block |
||
| 95 | 95 | * @param array $fields Fields. |
| 96 | 96 | * @return array |
| 97 | 97 | */ |
| 98 | - public function get_signature_fields( $fields = array() ) { |
|
| 99 | - foreach ( $this->get_order_items() as $item ) { |
|
| 100 | - $fields = $item->get_signature_fields( $fields ); |
|
| 98 | + public function get_signature_fields($fields = array()) { |
|
| 99 | + foreach ($this->get_order_items() as $item) { |
|
| 100 | + $fields = $item->get_signature_fields($fields); |
|
| 101 | 101 | } |
| 102 | 102 | |
| 103 | 103 | return $fields; |
@@ -44,7 +44,7 @@ discard block |
||
| 44 | 44 | * @param string $currency Authentication. |
| 45 | 45 | * @param int $amount Amount in cents. |
| 46 | 46 | */ |
| 47 | - public function __construct( $currency, $amount ) { |
|
| 47 | + public function __construct($currency, $amount) { |
|
| 48 | 48 | $this->currency = $currency; |
| 49 | 49 | $this->amount = $amount; |
| 50 | 50 | } |
@@ -86,13 +86,13 @@ discard block |
||
| 86 | 86 | * @return Money |
| 87 | 87 | * @throws InvalidArgumentException Throws invalid argument exception when object does not contains the required properties. |
| 88 | 88 | */ |
| 89 | - public static function from_object( stdClass $object ) { |
|
| 90 | - if ( ! isset( $object->currency ) ) { |
|
| 91 | - throw new InvalidArgumentException( 'Object must contain `currency` property.' ); |
|
| 89 | + public static function from_object(stdClass $object) { |
|
| 90 | + if ( ! isset($object->currency)) { |
|
| 91 | + throw new InvalidArgumentException('Object must contain `currency` property.'); |
|
| 92 | 92 | } |
| 93 | 93 | |
| 94 | - if ( ! isset( $object->amount ) ) { |
|
| 95 | - throw new InvalidArgumentException( 'Object must contain `amount` property.' ); |
|
| 94 | + if ( ! isset($object->amount)) { |
|
| 95 | + throw new InvalidArgumentException('Object must contain `amount` property.'); |
|
| 96 | 96 | } |
| 97 | 97 | |
| 98 | 98 | return new self( |
@@ -108,20 +108,20 @@ discard block |
||
| 108 | 108 | * @return Money |
| 109 | 109 | * @throws \JsonSchema\Exception\ValidationException Throws JSON schema validation exception when JSON is invalid. |
| 110 | 110 | */ |
| 111 | - public static function from_json( $json ) { |
|
| 112 | - $data = json_decode( $json ); |
|
| 111 | + public static function from_json($json) { |
|
| 112 | + $data = json_decode($json); |
|
| 113 | 113 | |
| 114 | 114 | $validator = new Validator(); |
| 115 | 115 | |
| 116 | 116 | $validator->validate( |
| 117 | 117 | $data, |
| 118 | 118 | (object) array( |
| 119 | - '$ref' => 'file://' . realpath( __DIR__ . '/../json-schemas/json-schema-money.json' ), |
|
| 119 | + '$ref' => 'file://' . realpath(__DIR__ . '/../json-schemas/json-schema-money.json'), |
|
| 120 | 120 | ), |
| 121 | 121 | Constraint::CHECK_MODE_EXCEPTIONS |
| 122 | 122 | ); |
| 123 | 123 | |
| 124 | - return self::from_object( $data ); |
|
| 124 | + return self::from_object($data); |
|
| 125 | 125 | } |
| 126 | 126 | |
| 127 | 127 | /** |
@@ -130,9 +130,9 @@ discard block |
||
| 130 | 130 | * @param array $fields Fields. |
| 131 | 131 | * @return array |
| 132 | 132 | */ |
| 133 | - public function get_signature_fields( $fields = array() ) { |
|
| 133 | + public function get_signature_fields($fields = array()) { |
|
| 134 | 134 | $fields[] = $this->get_currency(); |
| 135 | - $fields[] = strval( $this->get_amount() ); |
|
| 135 | + $fields[] = strval($this->get_amount()); |
|
| 136 | 136 | |
| 137 | 137 | return $fields; |
| 138 | 138 | } |
@@ -28,8 +28,8 @@ discard block |
||
| 28 | 28 | * @param int $max Max length of value. |
| 29 | 29 | * @throws InvalidArgumentException Throws invalid argument exception when string is longer then max length. |
| 30 | 30 | */ |
| 31 | - public static function validate_an( $value, $max ) { |
|
| 32 | - if ( strlen( $value ) > $max ) { |
|
| 31 | + public static function validate_an($value, $max) { |
|
| 32 | + if (strlen($value) > $max) { |
|
| 33 | 33 | throw new InvalidArgumentException( |
| 34 | 34 | sprintf( |
| 35 | 35 | 'Value "%s" can not be longer then `%d`.', |
@@ -49,11 +49,11 @@ discard block |
||
| 49 | 49 | * @param int $max Max length of value. |
| 50 | 50 | * @throws InvalidArgumentException Throws invalid argument exception when value is not null and longer then max length. |
| 51 | 51 | */ |
| 52 | - public static function validate_null_or_an( $value, $max ) { |
|
| 53 | - if ( null === $value ) { |
|
| 52 | + public static function validate_null_or_an($value, $max) { |
|
| 53 | + if (null === $value) { |
|
| 54 | 54 | return true; |
| 55 | 55 | } |
| 56 | 56 | |
| 57 | - return self::validate_an( $value, $max ); |
|
| 57 | + return self::validate_an($value, $max); |
|
| 58 | 58 | } |
| 59 | 59 | } |
@@ -99,7 +99,7 @@ discard block |
||
| 99 | 99 | * @param string $city City. |
| 100 | 100 | * @param string $country_code Country code. |
| 101 | 101 | */ |
| 102 | - public function __construct( $last_name, $street, $postal_code, $city, $country_code ) { |
|
| 102 | + public function __construct($last_name, $street, $postal_code, $city, $country_code) { |
|
| 103 | 103 | $this->last_name = $last_name; |
| 104 | 104 | $this->street = $street; |
| 105 | 105 | $this->postal_code = $postal_code; |
@@ -121,7 +121,7 @@ discard block |
||
| 121 | 121 | * |
| 122 | 122 | * @param string $first_name First name. |
| 123 | 123 | */ |
| 124 | - public function set_first_name( $first_name ) { |
|
| 124 | + public function set_first_name($first_name) { |
|
| 125 | 125 | $this->first_name = $first_name; |
| 126 | 126 | } |
| 127 | 127 | |
@@ -139,7 +139,7 @@ discard block |
||
| 139 | 139 | * |
| 140 | 140 | * @param string $middle_name Middle name. |
| 141 | 141 | */ |
| 142 | - public function set_middle_name( $middle_name ) { |
|
| 142 | + public function set_middle_name($middle_name) { |
|
| 143 | 143 | $this->middle_name = $middle_name; |
| 144 | 144 | } |
| 145 | 145 | |
@@ -157,7 +157,7 @@ discard block |
||
| 157 | 157 | * |
| 158 | 158 | * @param string $last_name Last name. |
| 159 | 159 | */ |
| 160 | - public function set_last_name( $last_name ) { |
|
| 160 | + public function set_last_name($last_name) { |
|
| 161 | 161 | $this->last_name = $last_name; |
| 162 | 162 | } |
| 163 | 163 | |
@@ -175,7 +175,7 @@ discard block |
||
| 175 | 175 | * |
| 176 | 176 | * @param string $street Street. |
| 177 | 177 | */ |
| 178 | - public function set_street( $street ) { |
|
| 178 | + public function set_street($street) { |
|
| 179 | 179 | $this->street = $street; |
| 180 | 180 | } |
| 181 | 181 | |
@@ -193,7 +193,7 @@ discard block |
||
| 193 | 193 | * |
| 194 | 194 | * @param string|null $house_number House number. |
| 195 | 195 | */ |
| 196 | - public function set_house_number( $house_number ) { |
|
| 196 | + public function set_house_number($house_number) { |
|
| 197 | 197 | $this->house_number = $house_number; |
| 198 | 198 | } |
| 199 | 199 | |
@@ -211,7 +211,7 @@ discard block |
||
| 211 | 211 | * |
| 212 | 212 | * @param string|null $house_number_addition House number addition. |
| 213 | 213 | */ |
| 214 | - public function set_house_number_addition( $house_number_addition ) { |
|
| 214 | + public function set_house_number_addition($house_number_addition) { |
|
| 215 | 215 | $this->house_number_addition = $house_number_addition; |
| 216 | 216 | } |
| 217 | 217 | |
@@ -229,7 +229,7 @@ discard block |
||
| 229 | 229 | * |
| 230 | 230 | * @param string $postal_code Postal code. |
| 231 | 231 | */ |
| 232 | - public function set_postal_code( $postal_code ) { |
|
| 232 | + public function set_postal_code($postal_code) { |
|
| 233 | 233 | $this->postal_code = $postal_code; |
| 234 | 234 | } |
| 235 | 235 | |
@@ -247,7 +247,7 @@ discard block |
||
| 247 | 247 | * |
| 248 | 248 | * @param string $city City. |
| 249 | 249 | */ |
| 250 | - public function set_city( $city ) { |
|
| 250 | + public function set_city($city) { |
|
| 251 | 251 | $this->city = $city; |
| 252 | 252 | } |
| 253 | 253 | |
@@ -265,7 +265,7 @@ discard block |
||
| 265 | 265 | * |
| 266 | 266 | * @param string $country_code Country code. |
| 267 | 267 | */ |
| 268 | - public function set_country_code( $country_code ) { |
|
| 268 | + public function set_country_code($country_code) { |
|
| 269 | 269 | $this->country_code = $country_code; |
| 270 | 270 | } |
| 271 | 271 | |
@@ -282,11 +282,11 @@ discard block |
||
| 282 | 282 | $object->lastName = $this->last_name; |
| 283 | 283 | $object->street = $this->street; |
| 284 | 284 | |
| 285 | - if ( null !== $this->house_number ) { |
|
| 285 | + if (null !== $this->house_number) { |
|
| 286 | 286 | $object->houseNumber = $this->house_number; |
| 287 | 287 | } |
| 288 | 288 | |
| 289 | - if ( null !== $this->house_number_addition ) { |
|
| 289 | + if (null !== $this->house_number_addition) { |
|
| 290 | 290 | $object->houseNumberAddition = $this->house_number_addition; |
| 291 | 291 | } |
| 292 | 292 | |
@@ -303,17 +303,17 @@ discard block |
||
| 303 | 303 | * @param array $fields Fields. |
| 304 | 304 | * @return array |
| 305 | 305 | */ |
| 306 | - public function get_signature_fields( $fields = array() ) { |
|
| 306 | + public function get_signature_fields($fields = array()) { |
|
| 307 | 307 | $fields[] = $this->first_name; |
| 308 | 308 | $fields[] = $this->middle_name; |
| 309 | 309 | $fields[] = $this->last_name; |
| 310 | 310 | $fields[] = $this->street; |
| 311 | 311 | |
| 312 | - if ( null !== $this->house_number ) { |
|
| 312 | + if (null !== $this->house_number) { |
|
| 313 | 313 | $fields[] = $this->house_number; |
| 314 | 314 | } |
| 315 | 315 | |
| 316 | - if ( null !== $this->house_number_addition ) { |
|
| 316 | + if (null !== $this->house_number_addition) { |
|
| 317 | 317 | $fields[] = $this->house_number_addition; |
| 318 | 318 | } |
| 319 | 319 | |
@@ -82,7 +82,7 @@ discard block |
||
| 82 | 82 | * @param Money $amount Amount. |
| 83 | 83 | * @param string $category Category. |
| 84 | 84 | */ |
| 85 | - public function __construct( $name, $quantity, Money $amount, $category ) { |
|
| 85 | + public function __construct($name, $quantity, Money $amount, $category) { |
|
| 86 | 86 | $this->name = $name; |
| 87 | 87 | $this->quantity = $quantity; |
| 88 | 88 | $this->amount = $amount; |
@@ -103,7 +103,7 @@ discard block |
||
| 103 | 103 | * |
| 104 | 104 | * @param string|null $id ID. |
| 105 | 105 | */ |
| 106 | - public function set_id( $id = null ) { |
|
| 106 | + public function set_id($id = null) { |
|
| 107 | 107 | $this->id = $id; |
| 108 | 108 | } |
| 109 | 109 | |
@@ -130,7 +130,7 @@ discard block |
||
| 130 | 130 | * |
| 131 | 131 | * @param string|null $description Description. |
| 132 | 132 | */ |
| 133 | - public function set_description( $description ) { |
|
| 133 | + public function set_description($description) { |
|
| 134 | 134 | $this->description = $description; |
| 135 | 135 | } |
| 136 | 136 | |
@@ -166,7 +166,7 @@ discard block |
||
| 166 | 166 | * |
| 167 | 167 | * @param Money|null $tax Tax. |
| 168 | 168 | */ |
| 169 | - public function set_tax( Money $tax = null ) { |
|
| 169 | + public function set_tax(Money $tax = null) { |
|
| 170 | 170 | $this->tax = $tax; |
| 171 | 171 | } |
| 172 | 172 | |
@@ -193,7 +193,7 @@ discard block |
||
| 193 | 193 | * |
| 194 | 194 | * @param int|null $vat_category VAT category. |
| 195 | 195 | */ |
| 196 | - public function set_vat_category( $vat_category ) { |
|
| 196 | + public function set_vat_category($vat_category) { |
|
| 197 | 197 | $this->vat_category = $vat_category; |
| 198 | 198 | } |
| 199 | 199 | |
@@ -205,26 +205,26 @@ discard block |
||
| 205 | 205 | public function get_json() { |
| 206 | 206 | $object = (object) array(); |
| 207 | 207 | |
| 208 | - if ( null !== $this->id ) { |
|
| 208 | + if (null !== $this->id) { |
|
| 209 | 209 | $object->id = $this->id; |
| 210 | 210 | } |
| 211 | 211 | |
| 212 | 212 | $object->name = $this->name; |
| 213 | 213 | |
| 214 | - if ( null !== $this->description ) { |
|
| 214 | + if (null !== $this->description) { |
|
| 215 | 215 | $object->description = $this->description; |
| 216 | 216 | } |
| 217 | 217 | |
| 218 | 218 | $object->quantity = $this->quantity; |
| 219 | 219 | $object->amount = $this->amount->get_json(); |
| 220 | 220 | |
| 221 | - if ( null !== $this->tax ) { |
|
| 221 | + if (null !== $this->tax) { |
|
| 222 | 222 | $object->tax = $this->tax->get_json(); |
| 223 | 223 | } |
| 224 | 224 | |
| 225 | 225 | $object->category = $this->category; |
| 226 | 226 | |
| 227 | - if ( null !== $this->vat_category ) { |
|
| 227 | + if (null !== $this->vat_category) { |
|
| 228 | 228 | $object->vatCategory = $this->vat_category; |
| 229 | 229 | } |
| 230 | 230 | |
@@ -237,26 +237,26 @@ discard block |
||
| 237 | 237 | * @param array $fields Fields. |
| 238 | 238 | * @return array |
| 239 | 239 | */ |
| 240 | - public function get_signature_fields( $fields = array() ) { |
|
| 241 | - if ( null !== $this->id ) { |
|
| 240 | + public function get_signature_fields($fields = array()) { |
|
| 241 | + if (null !== $this->id) { |
|
| 242 | 242 | $fields[] = $this->id; |
| 243 | 243 | } |
| 244 | 244 | |
| 245 | 245 | $fields[] = $this->name; |
| 246 | 246 | $fields[] = $this->description; |
| 247 | - $fields[] = strval( $this->quantity ); |
|
| 247 | + $fields[] = strval($this->quantity); |
|
| 248 | 248 | |
| 249 | - $fields = $this->amount->get_signature_fields( $fields ); |
|
| 249 | + $fields = $this->amount->get_signature_fields($fields); |
|
| 250 | 250 | |
| 251 | - if ( null === $this->tax ) { |
|
| 251 | + if (null === $this->tax) { |
|
| 252 | 252 | $fields[] = null; |
| 253 | 253 | } else { |
| 254 | - $fields = $this->tax->get_signature_fields( $fields ); |
|
| 254 | + $fields = $this->tax->get_signature_fields($fields); |
|
| 255 | 255 | } |
| 256 | 256 | |
| 257 | 257 | $fields[] = $this->category; |
| 258 | 258 | |
| 259 | - if ( null !== $this->vat_category ) { |
|
| 259 | + if (null !== $this->vat_category) { |
|
| 260 | 260 | $fields[] = $this->vat_category; |
| 261 | 261 | } |
| 262 | 262 | |
@@ -26,8 +26,8 @@ discard block |
||
| 26 | 26 | * @param PronamicAddress|null $pronamic_address Pronamic address to convert. |
| 27 | 27 | * @return Address|null |
| 28 | 28 | */ |
| 29 | - public static function transform( PronamicAddress $pronamic_address = null ) { |
|
| 30 | - if ( null === $pronamic_address ) { |
|
| 29 | + public static function transform(PronamicAddress $pronamic_address = null) { |
|
| 30 | + if (null === $pronamic_address) { |
|
| 31 | 31 | return null; |
| 32 | 32 | } |
| 33 | 33 | |
@@ -39,19 +39,19 @@ discard block |
||
| 39 | 39 | $city = $pronamic_address->get_city(); |
| 40 | 40 | $country_code = $pronamic_address->get_country_code(); |
| 41 | 41 | |
| 42 | - if ( ! isset( $last_name, $street, $postal_code, $city, $country_code ) ) { |
|
| 42 | + if ( ! isset($last_name, $street, $postal_code, $city, $country_code)) { |
|
| 43 | 43 | return null; |
| 44 | 44 | } |
| 45 | 45 | |
| 46 | - $address = new Address( $last_name, $street, $postal_code, $city, $country_code ); |
|
| 46 | + $address = new Address($last_name, $street, $postal_code, $city, $country_code); |
|
| 47 | 47 | |
| 48 | - if ( null !== $name ) { |
|
| 49 | - $address->set_first_name( $name->get_first_name() ); |
|
| 50 | - $address->set_middle_name( $name->get_middle_name() ); |
|
| 48 | + if (null !== $name) { |
|
| 49 | + $address->set_first_name($name->get_first_name()); |
|
| 50 | + $address->set_middle_name($name->get_middle_name()); |
|
| 51 | 51 | } |
| 52 | 52 | |
| 53 | - $address->set_house_number( $pronamic_address->get_house_number() ); |
|
| 54 | - $address->set_house_number_addition( $pronamic_address->get_house_number_addition() ); |
|
| 53 | + $address->set_house_number($pronamic_address->get_house_number()); |
|
| 54 | + $address->set_house_number_addition($pronamic_address->get_house_number_addition()); |
|
| 55 | 55 | |
| 56 | 56 | return $address; |
| 57 | 57 | } |
@@ -35,10 +35,10 @@ |
||
| 35 | 35 | * |
| 36 | 36 | * @var callable $webhook_listener_function |
| 37 | 37 | */ |
| 38 | - $webhook_listener_function = array( __NAMESPACE__ . '\WebhookListener', 'listen' ); |
|
| 38 | + $webhook_listener_function = array(__NAMESPACE__ . '\WebhookListener', 'listen'); |
|
| 39 | 39 | |
| 40 | - if ( ! has_action( 'wp_loaded', $webhook_listener_function ) ) { |
|
| 41 | - add_action( 'wp_loaded', $webhook_listener_function ); |
|
| 40 | + if ( ! has_action('wp_loaded', $webhook_listener_function)) { |
|
| 41 | + add_action('wp_loaded', $webhook_listener_function); |
|
| 42 | 42 | } |
| 43 | 43 | } |
| 44 | 44 | |
@@ -85,7 +85,7 @@ discard block |
||
| 85 | 85 | * |
| 86 | 86 | * @param string $url URL. |
| 87 | 87 | */ |
| 88 | - public function set_url( $url ) { |
|
| 88 | + public function set_url($url) { |
|
| 89 | 89 | $this->url = $url; |
| 90 | 90 | } |
| 91 | 91 | |
@@ -103,7 +103,7 @@ discard block |
||
| 103 | 103 | * |
| 104 | 104 | * @param string $refresh_token Refresh token. |
| 105 | 105 | */ |
| 106 | - public function set_refresh_token( $refresh_token ) { |
|
| 106 | + public function set_refresh_token($refresh_token) { |
|
| 107 | 107 | $this->refresh_token = $refresh_token; |
| 108 | 108 | } |
| 109 | 109 | |
@@ -121,7 +121,7 @@ discard block |
||
| 121 | 121 | * |
| 122 | 122 | * @param string $signing_key Signing key. |
| 123 | 123 | */ |
| 124 | - public function set_signing_key( $signing_key ) { |
|
| 124 | + public function set_signing_key($signing_key) { |
|
| 125 | 125 | $this->signing_key = $signing_key; |
| 126 | 126 | } |
| 127 | 127 | |
@@ -133,7 +133,7 @@ discard block |
||
| 133 | 133 | * @param string $token Authorization token. |
| 134 | 134 | * @param object|null $object Object. |
| 135 | 135 | */ |
| 136 | - private function request( $method, $endpoint, $token, $object = null ) { |
|
| 136 | + private function request($method, $endpoint, $token, $object = null) { |
|
| 137 | 137 | // URL. |
| 138 | 138 | $url = $this->get_url() . $endpoint; |
| 139 | 139 | |
@@ -145,45 +145,45 @@ discard block |
||
| 145 | 145 | ), |
| 146 | 146 | ); |
| 147 | 147 | |
| 148 | - if ( null !== $object ) { |
|
| 148 | + if (null !== $object) { |
|
| 149 | 149 | $args['headers']['Content-Type'] = 'application/json'; |
| 150 | 150 | |
| 151 | - $args['body'] = wp_json_encode( $object ); |
|
| 151 | + $args['body'] = wp_json_encode($object); |
|
| 152 | 152 | } |
| 153 | 153 | |
| 154 | 154 | // Request. |
| 155 | - $response = wp_remote_request( $url, $args ); |
|
| 155 | + $response = wp_remote_request($url, $args); |
|
| 156 | 156 | |
| 157 | - if ( $response instanceof WP_Error ) { |
|
| 157 | + if ($response instanceof WP_Error) { |
|
| 158 | 158 | $this->error = $response; |
| 159 | 159 | |
| 160 | - $this->error->add( 'omnikassa_2_error', 'HTTP Request Failed' ); |
|
| 160 | + $this->error->add('omnikassa_2_error', 'HTTP Request Failed'); |
|
| 161 | 161 | |
| 162 | 162 | return false; |
| 163 | 163 | } |
| 164 | 164 | |
| 165 | 165 | // Body. |
| 166 | - $body = wp_remote_retrieve_body( $response ); |
|
| 166 | + $body = wp_remote_retrieve_body($response); |
|
| 167 | 167 | |
| 168 | - $data = json_decode( $body ); |
|
| 168 | + $data = json_decode($body); |
|
| 169 | 169 | |
| 170 | - if ( ! is_object( $data ) ) { |
|
| 171 | - $this->error = new WP_Error( 'omnikassa_2_error', 'Could not parse response.', $data ); |
|
| 170 | + if ( ! is_object($data)) { |
|
| 171 | + $this->error = new WP_Error('omnikassa_2_error', 'Could not parse response.', $data); |
|
| 172 | 172 | |
| 173 | 173 | return false; |
| 174 | 174 | } |
| 175 | 175 | |
| 176 | 176 | // Error. |
| 177 | - if ( isset( $data->errorCode ) ) { |
|
| 177 | + if (isset($data->errorCode)) { |
|
| 178 | 178 | $message = 'Unknown error.'; |
| 179 | 179 | |
| 180 | - if ( isset( $data->consumerMessage ) ) { |
|
| 180 | + if (isset($data->consumerMessage)) { |
|
| 181 | 181 | $message = $data->consumerMessage; |
| 182 | - } elseif ( isset( $data->errorMessage ) ) { |
|
| 182 | + } elseif (isset($data->errorMessage)) { |
|
| 183 | 183 | $message = $data->errorMessage; |
| 184 | 184 | } |
| 185 | 185 | |
| 186 | - $this->error = new WP_Error( 'omnikassa_2_error', $message, $data ); |
|
| 186 | + $this->error = new WP_Error('omnikassa_2_error', $message, $data); |
|
| 187 | 187 | |
| 188 | 188 | return false; |
| 189 | 189 | } |
@@ -198,7 +198,7 @@ discard block |
||
| 198 | 198 | * @return object|false |
| 199 | 199 | */ |
| 200 | 200 | public function get_access_token_data() { |
| 201 | - return $this->request( 'GET', 'gatekeeper/refresh', $this->get_refresh_token() ); |
|
| 201 | + return $this->request('GET', 'gatekeeper/refresh', $this->get_refresh_token()); |
|
| 202 | 202 | } |
| 203 | 203 | |
| 204 | 204 | /** |
@@ -208,18 +208,18 @@ discard block |
||
| 208 | 208 | * @param Order $order Order. |
| 209 | 209 | * @return OrderAnnounceResponse|false |
| 210 | 210 | */ |
| 211 | - public function order_announce( $config, Order $order ) { |
|
| 212 | - $order->sign( $config->signing_key ); |
|
| 211 | + public function order_announce($config, Order $order) { |
|
| 212 | + $order->sign($config->signing_key); |
|
| 213 | 213 | |
| 214 | 214 | $object = $order->get_json(); |
| 215 | 215 | |
| 216 | - $result = $this->request( 'POST', 'order/server/api/order', $config->access_token, $object ); |
|
| 216 | + $result = $this->request('POST', 'order/server/api/order', $config->access_token, $object); |
|
| 217 | 217 | |
| 218 | - if ( ! is_object( $result ) ) { |
|
| 218 | + if ( ! is_object($result)) { |
|
| 219 | 219 | return false; |
| 220 | 220 | } |
| 221 | 221 | |
| 222 | - return OrderAnnounceResponse::from_object( $result ); |
|
| 222 | + return OrderAnnounceResponse::from_object($result); |
|
| 223 | 223 | } |
| 224 | 224 | |
| 225 | 225 | /** |
@@ -229,13 +229,13 @@ discard block |
||
| 229 | 229 | * |
| 230 | 230 | * @return OrderResults|false |
| 231 | 231 | */ |
| 232 | - public function get_order_results( $notification_token ) { |
|
| 233 | - $result = $this->request( 'GET', 'order/server/api/events/results/merchant.order.status.changed', $notification_token ); |
|
| 232 | + public function get_order_results($notification_token) { |
|
| 233 | + $result = $this->request('GET', 'order/server/api/events/results/merchant.order.status.changed', $notification_token); |
|
| 234 | 234 | |
| 235 | - if ( ! is_object( $result ) ) { |
|
| 235 | + if ( ! is_object($result)) { |
|
| 236 | 236 | return false; |
| 237 | 237 | } |
| 238 | 238 | |
| 239 | - return OrderResults::from_object( $result ); |
|
| 239 | + return OrderResults::from_object($result); |
|
| 240 | 240 | } |
| 241 | 241 | } |
@@ -39,7 +39,7 @@ discard block |
||
| 39 | 39 | * |
| 40 | 40 | * @param string $signature Signature. |
| 41 | 41 | */ |
| 42 | - protected function set_signature( $signature ) { |
|
| 42 | + protected function set_signature($signature) { |
|
| 43 | 43 | $this->signature = $signature; |
| 44 | 44 | } |
| 45 | 45 | |
@@ -48,10 +48,10 @@ discard block |
||
| 48 | 48 | * |
| 49 | 49 | * @param string $signing_key Signing key. |
| 50 | 50 | */ |
| 51 | - public function sign( $signing_key ) { |
|
| 52 | - $signature = Security::get_signature( $this, $signing_key ); |
|
| 51 | + public function sign($signing_key) { |
|
| 52 | + $signature = Security::get_signature($this, $signing_key); |
|
| 53 | 53 | |
| 54 | - $this->set_signature( $signature ); |
|
| 54 | + $this->set_signature($signature); |
|
| 55 | 55 | } |
| 56 | 56 | |
| 57 | 57 | /** |
@@ -60,13 +60,13 @@ discard block |
||
| 60 | 60 | * @param string $signing_key Signing key. |
| 61 | 61 | * @return bool True if valid, false otherwise. |
| 62 | 62 | */ |
| 63 | - public function is_valid( $signing_key ) { |
|
| 64 | - $signature = Security::get_signature( $this, $signing_key ); |
|
| 63 | + public function is_valid($signing_key) { |
|
| 64 | + $signature = Security::get_signature($this, $signing_key); |
|
| 65 | 65 | |
| 66 | - if ( empty( $signature ) ) { |
|
| 66 | + if (empty($signature)) { |
|
| 67 | 67 | return false; |
| 68 | 68 | } |
| 69 | 69 | |
| 70 | - return Security::validate_signature( $signature, $this->get_signature() ); |
|
| 70 | + return Security::validate_signature($signature, $this->get_signature()); |
|
| 71 | 71 | } |
| 72 | 72 | } |