Skip to content

Commit 33a9a29

Browse files
committed
CS
1 parent 9608b6f commit 33a9a29

File tree

8 files changed

+131
-137
lines changed

8 files changed

+131
-137
lines changed

plugin/classes/Aplazame_History.php

Lines changed: 61 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -49,68 +49,65 @@ public function process( $orderId ) {
4949
wp_send_json( $historyOrders );
5050
}
5151

52-
/**
53-
* @return bool
54-
*/
55-
private function verifyAuthentication()
56-
{
57-
$privateKey = $this->private_api_key;
58-
59-
$authorization = $this->getAuthorizationFromRequest();
60-
if (!$authorization || empty($privateKey)) {
61-
return false;
62-
}
63-
64-
return ($authorization === $privateKey);
65-
}
66-
67-
private function getAuthorizationFromRequest()
68-
{
69-
$token = isset( $_GET['access_token'] ) ? stripslashes_deep( $_GET['access_token'] ) : false;
70-
if ($token) {
71-
return $token;
72-
}
73-
74-
if (function_exists('getallheaders')) {
75-
$headers = getallheaders();
76-
} else {
77-
$headers = $this->getallheaders();
78-
}
79-
$headers = array_change_key_case($headers, CASE_LOWER);
80-
81-
if (isset($headers['authorization'])) {
82-
return trim(str_replace('Bearer', '', $headers['authorization']));
83-
}
84-
85-
return false;
86-
}
87-
88-
private function getallheaders()
89-
{
90-
$headers = array();
91-
$copy_server = array(
92-
'CONTENT_TYPE' => 'content-type',
93-
'CONTENT_LENGTH' => 'content-length',
94-
'CONTENT_MD5' => 'content-md5',
95-
);
96-
97-
foreach ($_SERVER as $name => $value) {
98-
if (substr($name, 0, 5) === 'HTTP_') {
99-
$name = substr($name, 5);
100-
if (!isset($copy_server[$name]) || !isset($_SERVER[$name])) {
101-
$headers[str_replace(' ', '-', strtolower(str_replace('_', ' ', $name)))] = $value;
102-
}
103-
} elseif (isset($copy_server[$name])) {
104-
$headers[$copy_server[$name]] = $value;
105-
}
106-
}
107-
108-
if (!isset($headers['authorization'])) {
109-
if (isset($_SERVER['REDIRECT_HTTP_AUTHORIZATION'])) {
110-
$headers['authorization'] = $_SERVER['REDIRECT_HTTP_AUTHORIZATION'];
111-
}
112-
}
113-
114-
return $headers;
115-
}
52+
/**
53+
* @return bool
54+
*/
55+
private function verifyAuthentication() {
56+
$privateKey = $this->private_api_key;
57+
58+
$authorization = $this->getAuthorizationFromRequest();
59+
if ( ! $authorization || empty( $privateKey ) ) {
60+
return false;
61+
}
62+
63+
return ($authorization === $privateKey);
64+
}
65+
66+
private function getAuthorizationFromRequest() {
67+
$token = isset( $_GET['access_token'] ) ? stripslashes_deep( $_GET['access_token'] ) : false;
68+
if ( $token ) {
69+
return $token;
70+
}
71+
72+
if ( function_exists( 'getallheaders' ) ) {
73+
$headers = getallheaders();
74+
} else {
75+
$headers = $this->getallheaders();
76+
}
77+
$headers = array_change_key_case( $headers, CASE_LOWER );
78+
79+
if ( isset( $headers['authorization'] ) ) {
80+
return trim( str_replace( 'Bearer', '', $headers['authorization'] ) );
81+
}
82+
83+
return false;
84+
}
85+
86+
private function getallheaders() {
87+
$headers = array();
88+
$copy_server = array(
89+
'CONTENT_TYPE' => 'content-type',
90+
'CONTENT_LENGTH' => 'content-length',
91+
'CONTENT_MD5' => 'content-md5',
92+
);
93+
94+
foreach ( $_SERVER as $name => $value ) {
95+
if ( substr( $name, 0, 5 ) === 'HTTP_' ) {
96+
$name = substr( $name, 5 );
97+
if ( ! isset( $copy_server[ $name ] ) || ! isset( $_SERVER[ $name ] ) ) {
98+
$headers[ str_replace( ' ', '-', strtolower( str_replace( '_', ' ', $name ) ) ) ] = $value;
99+
}
100+
} elseif ( isset( $copy_server[ $name ] ) ) {
101+
$headers[ $copy_server[ $name ] ] = $value;
102+
}
103+
}
104+
105+
if ( ! isset( $headers['authorization'] ) ) {
106+
if ( isset( $_SERVER['REDIRECT_HTTP_AUTHORIZATION'] ) ) {
107+
$headers['authorization'] = $_SERVER['REDIRECT_HTTP_AUTHORIZATION'];
108+
}
109+
}
110+
111+
return $headers;
112+
}
116113
}

plugin/classes/api/Aplazame_Api_Router.php

Lines changed: 63 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ public function __construct( $private_api_key ) {
5454
* @param string $path
5555
* @param array $pathArguments
5656
* @param array $queryArguments
57-
* @param null|array $payload
57+
* @param null|array $payload
5858
*
5959
* @return void
6060
*/
@@ -70,7 +70,7 @@ public function process( $path, array $pathArguments, array $queryArguments, $pa
7070
* @param string $path
7171
* @param array $pathArguments
7272
* @param array $queryArguments
73-
* @param null|array $payload
73+
* @param null|array $payload
7474
*
7575
* @return array
7676
*/
@@ -95,68 +95,65 @@ public function route( $path, array $pathArguments, array $queryArguments, $payl
9595
}
9696
}
9797

98-
/**
99-
* @return bool
100-
*/
101-
private function verifyAuthentication()
102-
{
103-
$privateKey = $this->private_api_key;
104-
105-
$authorization = $this->getAuthorizationFromRequest();
106-
if (!$authorization || empty($privateKey)) {
107-
return false;
108-
}
109-
110-
return ($authorization === $privateKey);
111-
}
112-
113-
private function getAuthorizationFromRequest()
114-
{
115-
$token = isset( $_GET['access_token'] ) ? stripslashes_deep( $_GET['access_token'] ) : false;
116-
if ($token) {
117-
return $token;
118-
}
119-
120-
if (function_exists('getallheaders')) {
121-
$headers = getallheaders();
122-
} else {
123-
$headers = $this->getallheaders();
124-
}
125-
$headers = array_change_key_case($headers, CASE_LOWER);
126-
127-
if (isset($headers['authorization'])) {
128-
return trim(str_replace('Bearer', '', $headers['authorization']));
129-
}
130-
131-
return false;
132-
}
133-
134-
private function getallheaders()
135-
{
136-
$headers = array();
137-
$copy_server = array(
138-
'CONTENT_TYPE' => 'content-type',
139-
'CONTENT_LENGTH' => 'content-length',
140-
'CONTENT_MD5' => 'content-md5',
141-
);
142-
143-
foreach ($_SERVER as $name => $value) {
144-
if (substr($name, 0, 5) === 'HTTP_') {
145-
$name = substr($name, 5);
146-
if (!isset($copy_server[$name]) || !isset($_SERVER[$name])) {
147-
$headers[str_replace(' ', '-', strtolower(str_replace('_', ' ', $name)))] = $value;
148-
}
149-
} elseif (isset($copy_server[$name])) {
150-
$headers[$copy_server[$name]] = $value;
151-
}
152-
}
153-
154-
if (!isset($headers['authorization'])) {
155-
if (isset($_SERVER['REDIRECT_HTTP_AUTHORIZATION'])) {
156-
$headers['authorization'] = $_SERVER['REDIRECT_HTTP_AUTHORIZATION'];
157-
}
158-
}
159-
160-
return $headers;
161-
}
98+
/**
99+
* @return bool
100+
*/
101+
private function verifyAuthentication() {
102+
$privateKey = $this->private_api_key;
103+
104+
$authorization = $this->getAuthorizationFromRequest();
105+
if ( ! $authorization || empty( $privateKey ) ) {
106+
return false;
107+
}
108+
109+
return ($authorization === $privateKey);
110+
}
111+
112+
private function getAuthorizationFromRequest() {
113+
$token = isset( $_GET['access_token'] ) ? stripslashes_deep( $_GET['access_token'] ) : false;
114+
if ( $token ) {
115+
return $token;
116+
}
117+
118+
if ( function_exists( 'getallheaders' ) ) {
119+
$headers = getallheaders();
120+
} else {
121+
$headers = $this->getallheaders();
122+
}
123+
$headers = array_change_key_case( $headers, CASE_LOWER );
124+
125+
if ( isset( $headers['authorization'] ) ) {
126+
return trim( str_replace( 'Bearer', '', $headers['authorization'] ) );
127+
}
128+
129+
return false;
130+
}
131+
132+
private function getallheaders() {
133+
$headers = array();
134+
$copy_server = array(
135+
'CONTENT_TYPE' => 'content-type',
136+
'CONTENT_LENGTH' => 'content-length',
137+
'CONTENT_MD5' => 'content-md5',
138+
);
139+
140+
foreach ( $_SERVER as $name => $value ) {
141+
if ( substr( $name, 0, 5 ) === 'HTTP_' ) {
142+
$name = substr( $name, 5 );
143+
if ( ! isset( $copy_server[ $name ] ) || ! isset( $_SERVER[ $name ] ) ) {
144+
$headers[ str_replace( ' ', '-', strtolower( str_replace( '_', ' ', $name ) ) ) ] = $value;
145+
}
146+
} elseif ( isset( $copy_server[ $name ] ) ) {
147+
$headers[ $copy_server[ $name ] ] = $value;
148+
}
149+
}
150+
151+
if ( ! isset( $headers['authorization'] ) ) {
152+
if ( isset( $_SERVER['REDIRECT_HTTP_AUTHORIZATION'] ) ) {
153+
$headers['authorization'] = $_SERVER['REDIRECT_HTTP_AUTHORIZATION'];
154+
}
155+
}
156+
157+
return $headers;
158+
}
162159
}

plugin/lib/Aplazame/Aplazame/Api/BusinessModel/Article.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
class Aplazame_Aplazame_Api_BusinessModel_Article {
44
public static function createFromProduct( WC_Product $product ) {
5-
if (method_exists($product, 'get_id')) {
5+
if ( method_exists( $product, 'get_id' ) ) {
66
$product_id = $product->get_id();
77
} else {
88
$product_id = $product->id;

plugin/lib/Aplazame/Aplazame/Api/BusinessModel/HistoricalOrder.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
class Aplazame_Aplazame_Api_BusinessModel_HistoricalOrder {
44

55
public static function createFromOrder( WC_Order $order ) {
6-
if (method_exists($order, 'get_id')) {
6+
if ( method_exists( $order, 'get_id' ) ) {
77
$order_id = $order->get_id();
88
} else {
99
$order_id = $order->id;

plugin/lib/Aplazame/Aplazame/BusinessModel/Address.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public static function createFromOrder( WC_Order $order, $type ) {
2323
) as $key => $field ) {
2424
$field = $type . '_' . $field;
2525

26-
if (method_exists($order, 'get_' . $field)) {
26+
if ( method_exists( $order, 'get_' . $field ) ) {
2727
$aAddress->$key = $order->{'get_' . $field}();
2828
} else {
2929
$aAddress->$key = $order->$field;

plugin/lib/Aplazame/Aplazame/BusinessModel/Article.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@ class Aplazame_Aplazame_BusinessModel_Article {
77

88
public static function createFromOrderItem( $item ) {
99
if ( $item instanceof WC_Order_Item_Product ) {
10-
return self::createFromOrderItemProduct($item);
10+
return self::createFromOrderItemProduct( $item );
1111
}
1212

13-
return self::createFromOrderItemArray($item);
13+
return self::createFromOrderItemArray( $item );
1414
}
1515

1616
public static function createFromOrderItemArray( array $values ) {

plugin/lib/Aplazame/Aplazame/BusinessModel/Customer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public static function createFromUser( WP_User $user ) {
4646

4747
public static function createGuessCustomerFromOrder( WC_Order $order ) {
4848
$aCustomer = new self();
49-
if (method_exists($order, 'get_id')) {
49+
if ( method_exists( $order, 'get_id' ) ) {
5050
$aCustomer->email = $order->get_billing_email();
5151
} else {
5252
$aCustomer->email = $order->billing_email;

plugin/lib/Aplazame/Aplazame/BusinessModel/Order.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
class Aplazame_Aplazame_BusinessModel_Order {
77

88
public static function crateFromOrder( WC_Order $order ) {
9-
if (method_exists($order, 'get_id')) {
9+
if ( method_exists( $order, 'get_id' ) ) {
1010
$order_id = $order->get_id();
1111
} else {
1212
$order_id = $order->id;

0 commit comments

Comments
 (0)