@@ -26,16 +26,16 @@ |
||
26 | 26 | |
27 | 27 | class ParserFactory |
28 | 28 | { |
29 | - public function createCsvParser(): CsvParser |
|
30 | - { |
|
31 | - return new CsvParser(); |
|
32 | - } |
|
33 | - public function createJsonParser(): JsonParser |
|
34 | - { |
|
35 | - return new JsonParser(); |
|
36 | - } |
|
37 | - public function createOfxParser(): OfxParser |
|
38 | - { |
|
39 | - return new OfxParser(); |
|
40 | - } |
|
29 | + public function createCsvParser(): CsvParser |
|
30 | + { |
|
31 | + return new CsvParser(); |
|
32 | + } |
|
33 | + public function createJsonParser(): JsonParser |
|
34 | + { |
|
35 | + return new JsonParser(); |
|
36 | + } |
|
37 | + public function createOfxParser(): OfxParser |
|
38 | + { |
|
39 | + return new OfxParser(); |
|
40 | + } |
|
41 | 41 | } |
42 | 42 | \ No newline at end of file |
@@ -28,43 +28,43 @@ |
||
28 | 28 | protected $order; |
29 | 29 | protected $invoiceDate; |
30 | 30 | |
31 | - /** |
|
32 | - * @return mixed |
|
33 | - */ |
|
34 | - public function getOrder() |
|
35 | - { |
|
36 | - return $this->order; |
|
37 | - } |
|
31 | + /** |
|
32 | + * @return mixed |
|
33 | + */ |
|
34 | + public function getOrder() |
|
35 | + { |
|
36 | + return $this->order; |
|
37 | + } |
|
38 | 38 | |
39 | - /** |
|
40 | - * @param mixed $order |
|
41 | - * |
|
42 | - * @return self |
|
43 | - */ |
|
44 | - public function setOrder(Order $order) |
|
45 | - { |
|
46 | - $this->order = $order; |
|
39 | + /** |
|
40 | + * @param mixed $order |
|
41 | + * |
|
42 | + * @return self |
|
43 | + */ |
|
44 | + public function setOrder(Order $order) |
|
45 | + { |
|
46 | + $this->order = $order; |
|
47 | 47 | |
48 | - return $this; |
|
49 | - } |
|
48 | + return $this; |
|
49 | + } |
|
50 | 50 | |
51 | - /** |
|
52 | - * @return mixed |
|
53 | - */ |
|
54 | - public function getInvoiceDate() |
|
55 | - { |
|
56 | - return $this->invoiceDate; |
|
57 | - } |
|
51 | + /** |
|
52 | + * @return mixed |
|
53 | + */ |
|
54 | + public function getInvoiceDate() |
|
55 | + { |
|
56 | + return $this->invoiceDate; |
|
57 | + } |
|
58 | 58 | |
59 | - /** |
|
60 | - * @param mixed $invoiceDate |
|
61 | - * |
|
62 | - * @return self |
|
63 | - */ |
|
64 | - public function setInvoiceDate($invoiceDate) |
|
65 | - { |
|
66 | - $this->invoiceDate = $invoiceDate; |
|
59 | + /** |
|
60 | + * @param mixed $invoiceDate |
|
61 | + * |
|
62 | + * @return self |
|
63 | + */ |
|
64 | + public function setInvoiceDate($invoiceDate) |
|
65 | + { |
|
66 | + $this->invoiceDate = $invoiceDate; |
|
67 | 67 | |
68 | - return $this; |
|
69 | - } |
|
68 | + return $this; |
|
69 | + } |
|
70 | 70 | } |
71 | 71 | \ No newline at end of file |
@@ -27,43 +27,43 @@ |
||
27 | 27 | protected $customer; |
28 | 28 | protected $orderNumber; |
29 | 29 | |
30 | - /** |
|
31 | - * @return mixed |
|
32 | - */ |
|
33 | - public function getCustomer() |
|
34 | - { |
|
35 | - return $this->customer; |
|
36 | - } |
|
30 | + /** |
|
31 | + * @return mixed |
|
32 | + */ |
|
33 | + public function getCustomer() |
|
34 | + { |
|
35 | + return $this->customer; |
|
36 | + } |
|
37 | 37 | |
38 | - /** |
|
39 | - * @param mixed $customer |
|
40 | - * |
|
41 | - * @return self |
|
42 | - */ |
|
43 | - public function setCustomer($customer) |
|
44 | - { |
|
45 | - $this->customer = $customer; |
|
38 | + /** |
|
39 | + * @param mixed $customer |
|
40 | + * |
|
41 | + * @return self |
|
42 | + */ |
|
43 | + public function setCustomer($customer) |
|
44 | + { |
|
45 | + $this->customer = $customer; |
|
46 | 46 | |
47 | - return $this; |
|
48 | - } |
|
47 | + return $this; |
|
48 | + } |
|
49 | 49 | |
50 | - /** |
|
51 | - * @return mixed |
|
52 | - */ |
|
53 | - public function getOrderNumber() |
|
54 | - { |
|
55 | - return $this->orderNumber; |
|
56 | - } |
|
50 | + /** |
|
51 | + * @return mixed |
|
52 | + */ |
|
53 | + public function getOrderNumber() |
|
54 | + { |
|
55 | + return $this->orderNumber; |
|
56 | + } |
|
57 | 57 | |
58 | - /** |
|
59 | - * @param mixed $orderNumber |
|
60 | - * |
|
61 | - * @return self |
|
62 | - */ |
|
63 | - public function setOrderNumber($orderNumber) |
|
64 | - { |
|
65 | - $this->orderNumber = $orderNumber; |
|
58 | + /** |
|
59 | + * @param mixed $orderNumber |
|
60 | + * |
|
61 | + * @return self |
|
62 | + */ |
|
63 | + public function setOrderNumber($orderNumber) |
|
64 | + { |
|
65 | + $this->orderNumber = $orderNumber; |
|
66 | 66 | |
67 | - return $this; |
|
68 | - } |
|
67 | + return $this; |
|
68 | + } |
|
69 | 69 | } |
70 | 70 | \ No newline at end of file |
@@ -30,69 +30,69 @@ |
||
30 | 30 | $this->UserAgent = $_SERVER['HTTP_USER_AGENT']; |
31 | 31 | $this->UserIP = $this->__getUserIP(); |
32 | 32 | } |
33 | - /** |
|
34 | - * @return mixed |
|
35 | - */ |
|
36 | - public function getUserAgent() |
|
37 | - { |
|
38 | - return $this->UserAgent; |
|
39 | - } |
|
33 | + /** |
|
34 | + * @return mixed |
|
35 | + */ |
|
36 | + public function getUserAgent() |
|
37 | + { |
|
38 | + return $this->UserAgent; |
|
39 | + } |
|
40 | 40 | |
41 | - /** |
|
42 | - * @param mixed $UserAgent |
|
43 | - * |
|
44 | - * @return self |
|
45 | - */ |
|
46 | - public function setUserAgent($UserAgent) |
|
47 | - { |
|
48 | - $this->UserAgent = $UserAgent; |
|
41 | + /** |
|
42 | + * @param mixed $UserAgent |
|
43 | + * |
|
44 | + * @return self |
|
45 | + */ |
|
46 | + public function setUserAgent($UserAgent) |
|
47 | + { |
|
48 | + $this->UserAgent = $UserAgent; |
|
49 | 49 | |
50 | - return $this; |
|
51 | - } |
|
50 | + return $this; |
|
51 | + } |
|
52 | 52 | |
53 | - /** |
|
54 | - * @return mixed |
|
55 | - */ |
|
56 | - public function getUserIP() |
|
57 | - { |
|
58 | - return $this->UserIP; |
|
59 | - } |
|
53 | + /** |
|
54 | + * @return mixed |
|
55 | + */ |
|
56 | + public function getUserIP() |
|
57 | + { |
|
58 | + return $this->UserIP; |
|
59 | + } |
|
60 | 60 | |
61 | - /** |
|
62 | - * @param mixed $UserIP |
|
63 | - * |
|
64 | - * @return self |
|
65 | - */ |
|
66 | - public function setUserIP($UserIP) |
|
67 | - { |
|
68 | - $this->UserIP = $UserIP; |
|
61 | + /** |
|
62 | + * @param mixed $UserIP |
|
63 | + * |
|
64 | + * @return self |
|
65 | + */ |
|
66 | + public function setUserIP($UserIP) |
|
67 | + { |
|
68 | + $this->UserIP = $UserIP; |
|
69 | 69 | |
70 | - return $this; |
|
71 | - } |
|
72 | - private function __getUserIP() |
|
73 | - { |
|
74 | - // Get real visitor IP behind CloudFlare network |
|
75 | - if (isset($_SERVER["HTTP_CF_CONNECTING_IP"])) { |
|
76 | - $_SERVER['REMOTE_ADDR'] = $_SERVER["HTTP_CF_CONNECTING_IP"]; |
|
77 | - $_SERVER['HTTP_CLIENT_IP'] = $_SERVER["HTTP_CF_CONNECTING_IP"]; |
|
78 | - } |
|
79 | - $client = @$_SERVER['HTTP_CLIENT_IP']; |
|
80 | - $forward = @$_SERVER['HTTP_X_FORWARDED_FOR']; |
|
81 | - $remote = $_SERVER['REMOTE_ADDR']; |
|
70 | + return $this; |
|
71 | + } |
|
72 | + private function __getUserIP() |
|
73 | + { |
|
74 | + // Get real visitor IP behind CloudFlare network |
|
75 | + if (isset($_SERVER["HTTP_CF_CONNECTING_IP"])) { |
|
76 | + $_SERVER['REMOTE_ADDR'] = $_SERVER["HTTP_CF_CONNECTING_IP"]; |
|
77 | + $_SERVER['HTTP_CLIENT_IP'] = $_SERVER["HTTP_CF_CONNECTING_IP"]; |
|
78 | + } |
|
79 | + $client = @$_SERVER['HTTP_CLIENT_IP']; |
|
80 | + $forward = @$_SERVER['HTTP_X_FORWARDED_FOR']; |
|
81 | + $remote = $_SERVER['REMOTE_ADDR']; |
|
82 | 82 | |
83 | - if(filter_var($client, FILTER_VALIDATE_IP)) |
|
84 | - { |
|
85 | - $ip = $client; |
|
86 | - } |
|
87 | - elseif(filter_var($forward, FILTER_VALIDATE_IP)) |
|
88 | - { |
|
89 | - $ip = $forward; |
|
90 | - } |
|
91 | - else |
|
92 | - { |
|
93 | - $ip = $remote; |
|
94 | - } |
|
83 | + if(filter_var($client, FILTER_VALIDATE_IP)) |
|
84 | + { |
|
85 | + $ip = $client; |
|
86 | + } |
|
87 | + elseif(filter_var($forward, FILTER_VALIDATE_IP)) |
|
88 | + { |
|
89 | + $ip = $forward; |
|
90 | + } |
|
91 | + else |
|
92 | + { |
|
93 | + $ip = $remote; |
|
94 | + } |
|
95 | 95 | |
96 | - return $ip; |
|
97 | - } |
|
96 | + return $ip; |
|
97 | + } |
|
98 | 98 | } |
99 | 99 | \ No newline at end of file |
@@ -23,18 +23,18 @@ |
||
23 | 23 | |
24 | 24 | class OfxParser implements ParserInterface |
25 | 25 | { |
26 | - public function parse($filePath) |
|
27 | - { |
|
28 | - $ofxParser = new \OfxParser\Parser(); |
|
29 | - $ofx = $ofxParser->loadFromFile($filePath); |
|
26 | + public function parse($filePath) |
|
27 | + { |
|
28 | + $ofxParser = new \OfxParser\Parser(); |
|
29 | + $ofx = $ofxParser->loadFromFile($filePath); |
|
30 | 30 | |
31 | - $bankAccount = reset($ofx->bankAccounts); |
|
31 | + $bankAccount = reset($ofx->bankAccounts); |
|
32 | 32 | |
33 | - // Get the statement start and end dates |
|
34 | - $startDate = $bankAccount->statement->startDate; |
|
35 | - $endDate = $bankAccount->statement->endDate; |
|
33 | + // Get the statement start and end dates |
|
34 | + $startDate = $bankAccount->statement->startDate; |
|
35 | + $endDate = $bankAccount->statement->endDate; |
|
36 | 36 | |
37 | - // Get the statement transactions for the account |
|
38 | - return $bankAccount->statement->transactions; |
|
39 | - } |
|
37 | + // Get the statement transactions for the account |
|
38 | + return $bankAccount->statement->transactions; |
|
39 | + } |
|
40 | 40 | } |
@@ -24,354 +24,354 @@ |
||
24 | 24 | |
25 | 25 | class CsvParser implements ParserInterface { |
26 | 26 | |
27 | - private $handle = ""; |
|
28 | - private $filepath = FALSE; |
|
29 | - private $column_headers = FALSE; |
|
30 | - private $initial_line = 0; |
|
31 | - private $delimiter = ","; |
|
32 | - private $detect_line_endings = FALSE; |
|
27 | + private $handle = ""; |
|
28 | + private $filepath = FALSE; |
|
29 | + private $column_headers = FALSE; |
|
30 | + private $initial_line = 0; |
|
31 | + private $delimiter = ","; |
|
32 | + private $detect_line_endings = FALSE; |
|
33 | 33 | |
34 | 34 | /** |
35 | - * Function that parses a CSV file and returns results |
|
36 | - * as an array. |
|
37 | - * |
|
38 | - * @access public |
|
39 | - * @param filepath string Location of the CSV file |
|
40 | - * @param column_headers array Alternate values that will be used for array keys instead of first line of CSV |
|
41 | - * @param detect_line_endings boolean When true sets the php INI settings to allow script to detect line endings. Needed for CSV files created on Macs. |
|
42 | - * @param initial_line integer Sets the line of the file from which start parsing data. |
|
43 | - * @param delimiter string The values delimiter (e.g. ";" or ","). |
|
44 | - * @return array |
|
45 | - */ |
|
46 | - public function parse($filepath=FALSE, $column_headers=FALSE, $detect_line_endings=FALSE, $initial_line=FALSE, $delimiter=FALSE) |
|
47 | - { |
|
48 | - // Raise memory limit (for big files) |
|
49 | - ini_set('memory_limit', '128M'); |
|
35 | + * Function that parses a CSV file and returns results |
|
36 | + * as an array. |
|
37 | + * |
|
38 | + * @access public |
|
39 | + * @param filepath string Location of the CSV file |
|
40 | + * @param column_headers array Alternate values that will be used for array keys instead of first line of CSV |
|
41 | + * @param detect_line_endings boolean When true sets the php INI settings to allow script to detect line endings. Needed for CSV files created on Macs. |
|
42 | + * @param initial_line integer Sets the line of the file from which start parsing data. |
|
43 | + * @param delimiter string The values delimiter (e.g. ";" or ","). |
|
44 | + * @return array |
|
45 | + */ |
|
46 | + public function parse($filepath=FALSE, $column_headers=FALSE, $detect_line_endings=FALSE, $initial_line=FALSE, $delimiter=FALSE) |
|
47 | + { |
|
48 | + // Raise memory limit (for big files) |
|
49 | + ini_set('memory_limit', '128M'); |
|
50 | 50 | |
51 | - // File path |
|
52 | - if(! $filepath) |
|
53 | - { |
|
54 | - $filepath = $this->_get_filepath(); |
|
55 | - } |
|
56 | - else |
|
57 | - { |
|
58 | - // If filepath provided, set it |
|
59 | - $this->_set_filepath($filepath); |
|
60 | - } |
|
61 | - |
|
62 | - // If file doesn't exists, return false |
|
63 | - if(! file_exists($filepath)) |
|
64 | - { |
|
65 | - return FALSE; |
|
66 | - } |
|
67 | - |
|
68 | - // auto detect row endings |
|
69 | - if(! $detect_line_endings) |
|
70 | - { |
|
71 | - $detect_line_endings = $this->_get_detect_line_endings(); |
|
72 | - } |
|
73 | - else |
|
74 | - { |
|
75 | - // If detect_line_endings provided, set it |
|
76 | - $this->_set_detect_line_endings($detect_line_endings); |
|
77 | - } |
|
78 | - |
|
79 | - // If true, auto detect row endings |
|
80 | - if($detect_line_endings) |
|
81 | - { |
|
82 | - ini_set("auto_detect_line_endings", TRUE); |
|
83 | - } |
|
84 | - |
|
85 | - // Parse from this line on |
|
86 | - if(! $initial_line) |
|
87 | - { |
|
88 | - $initial_line = $this->_get_initial_line(); |
|
89 | - } |
|
90 | - else |
|
91 | - { |
|
92 | - $this->_set_initial_line($initial_line); |
|
93 | - } |
|
94 | - |
|
95 | - // Delimiter |
|
96 | - if(! $delimiter) |
|
97 | - { |
|
98 | - $delimiter = $this->_get_delimiter(); |
|
99 | - } |
|
100 | - else |
|
101 | - { |
|
102 | - // If delimiter provided, set it |
|
103 | - $this->_set_delimiter($delimiter); |
|
104 | - } |
|
105 | - |
|
106 | - // Column headers |
|
107 | - if(! $column_headers) |
|
108 | - { |
|
109 | - $column_headers = $this->_get_column_headers(); |
|
110 | - } |
|
111 | - else |
|
112 | - { |
|
113 | - // If column headers provided, set them |
|
114 | - $this->_set_column_headers($column_headers); |
|
115 | - } |
|
116 | - |
|
117 | - // Open the CSV for reading |
|
118 | - $this->_get_handle(); |
|
51 | + // File path |
|
52 | + if(! $filepath) |
|
53 | + { |
|
54 | + $filepath = $this->_get_filepath(); |
|
55 | + } |
|
56 | + else |
|
57 | + { |
|
58 | + // If filepath provided, set it |
|
59 | + $this->_set_filepath($filepath); |
|
60 | + } |
|
61 | + |
|
62 | + // If file doesn't exists, return false |
|
63 | + if(! file_exists($filepath)) |
|
64 | + { |
|
65 | + return FALSE; |
|
66 | + } |
|
67 | + |
|
68 | + // auto detect row endings |
|
69 | + if(! $detect_line_endings) |
|
70 | + { |
|
71 | + $detect_line_endings = $this->_get_detect_line_endings(); |
|
72 | + } |
|
73 | + else |
|
74 | + { |
|
75 | + // If detect_line_endings provided, set it |
|
76 | + $this->_set_detect_line_endings($detect_line_endings); |
|
77 | + } |
|
78 | + |
|
79 | + // If true, auto detect row endings |
|
80 | + if($detect_line_endings) |
|
81 | + { |
|
82 | + ini_set("auto_detect_line_endings", TRUE); |
|
83 | + } |
|
84 | + |
|
85 | + // Parse from this line on |
|
86 | + if(! $initial_line) |
|
87 | + { |
|
88 | + $initial_line = $this->_get_initial_line(); |
|
89 | + } |
|
90 | + else |
|
91 | + { |
|
92 | + $this->_set_initial_line($initial_line); |
|
93 | + } |
|
94 | + |
|
95 | + // Delimiter |
|
96 | + if(! $delimiter) |
|
97 | + { |
|
98 | + $delimiter = $this->_get_delimiter(); |
|
99 | + } |
|
100 | + else |
|
101 | + { |
|
102 | + // If delimiter provided, set it |
|
103 | + $this->_set_delimiter($delimiter); |
|
104 | + } |
|
105 | + |
|
106 | + // Column headers |
|
107 | + if(! $column_headers) |
|
108 | + { |
|
109 | + $column_headers = $this->_get_column_headers(); |
|
110 | + } |
|
111 | + else |
|
112 | + { |
|
113 | + // If column headers provided, set them |
|
114 | + $this->_set_column_headers($column_headers); |
|
115 | + } |
|
116 | + |
|
117 | + // Open the CSV for reading |
|
118 | + $this->_get_handle(); |
|
119 | 119 | |
120 | - $row = 0; |
|
121 | - |
|
122 | - while (($data = fgetcsv($this->handle, 0, $this->delimiter)) !== FALSE) |
|
123 | - { |
|
124 | - if ($data[0] != NULL) |
|
125 | - { |
|
126 | - if($row < $this->initial_line) |
|
127 | - { |
|
128 | - $row++; |
|
129 | - continue; |
|
130 | - } |
|
131 | - |
|
132 | - // If first row, parse for column_headers |
|
133 | - if($row == $this->initial_line) |
|
134 | - { |
|
135 | - // If column_headers already provided, use them |
|
136 | - if($this->column_headers) |
|
137 | - { |
|
138 | - foreach ($this->column_headers as $key => $value) |
|
139 | - { |
|
140 | - $column_headers[$key] = trim($value); |
|
141 | - } |
|
142 | - } |
|
143 | - else // Parse first row for column_headers to use |
|
144 | - { |
|
145 | - foreach ($data as $key => $value) |
|
146 | - { |
|
147 | - $column_headers[$key] = trim($value); |
|
148 | - } |
|
149 | - } |
|
150 | - } |
|
151 | - else |
|
152 | - { |
|
153 | - $new_row = $row - $this->initial_line - 1; // needed so that the returned array starts at 0 instead of 1 |
|
154 | - foreach($column_headers as $key => $value) // assumes there are as many columns as their are title columns |
|
155 | - { |
|
156 | - $result[$new_row][$value] = utf8_encode(trim($data[$key])); |
|
157 | - } |
|
158 | - } |
|
120 | + $row = 0; |
|
121 | + |
|
122 | + while (($data = fgetcsv($this->handle, 0, $this->delimiter)) !== FALSE) |
|
123 | + { |
|
124 | + if ($data[0] != NULL) |
|
125 | + { |
|
126 | + if($row < $this->initial_line) |
|
127 | + { |
|
128 | + $row++; |
|
129 | + continue; |
|
130 | + } |
|
131 | + |
|
132 | + // If first row, parse for column_headers |
|
133 | + if($row == $this->initial_line) |
|
134 | + { |
|
135 | + // If column_headers already provided, use them |
|
136 | + if($this->column_headers) |
|
137 | + { |
|
138 | + foreach ($this->column_headers as $key => $value) |
|
139 | + { |
|
140 | + $column_headers[$key] = trim($value); |
|
141 | + } |
|
142 | + } |
|
143 | + else // Parse first row for column_headers to use |
|
144 | + { |
|
145 | + foreach ($data as $key => $value) |
|
146 | + { |
|
147 | + $column_headers[$key] = trim($value); |
|
148 | + } |
|
149 | + } |
|
150 | + } |
|
151 | + else |
|
152 | + { |
|
153 | + $new_row = $row - $this->initial_line - 1; // needed so that the returned array starts at 0 instead of 1 |
|
154 | + foreach($column_headers as $key => $value) // assumes there are as many columns as their are title columns |
|
155 | + { |
|
156 | + $result[$new_row][$value] = utf8_encode(trim($data[$key])); |
|
157 | + } |
|
158 | + } |
|
159 | 159 | |
160 | - unset($data); |
|
160 | + unset($data); |
|
161 | 161 | |
162 | - $row++; |
|
163 | - } |
|
164 | - } |
|
162 | + $row++; |
|
163 | + } |
|
164 | + } |
|
165 | 165 | |
166 | - $this->_close_csv(); |
|
166 | + $this->_close_csv(); |
|
167 | 167 | |
168 | - return $result; |
|
169 | - } |
|
168 | + return $result; |
|
169 | + } |
|
170 | 170 | |
171 | 171 | |
172 | 172 | |
173 | - /** |
|
174 | - * Sets the "detect_line_endings" flag |
|
175 | - * |
|
176 | - * @access private |
|
177 | - * @param detect_line_endings bool The flag bit |
|
178 | - * @return void |
|
179 | - */ |
|
180 | - private function _set_detect_line_endings($detect_line_endings) |
|
181 | - { |
|
182 | - $this->detect_line_endings = $detect_line_endings; |
|
183 | - } |
|
184 | - |
|
185 | - /** |
|
186 | - * Sets the "detect_line_endings" flag |
|
187 | - * |
|
188 | - * @access public |
|
189 | - * @param detect_line_endings bool The flag bit |
|
190 | - * @return void |
|
191 | - */ |
|
192 | - public function detect_line_endings($detect_line_endings) |
|
193 | - { |
|
194 | - $this->_set_detect_line_endings($detect_line_endings); |
|
195 | - return $this; |
|
196 | - } |
|
197 | - |
|
198 | - /** |
|
199 | - * Gets the "detect_line_endings" flag |
|
200 | - * |
|
201 | - * @access private |
|
202 | - * @return bool |
|
203 | - */ |
|
204 | - private function _get_detect_line_endings() |
|
205 | - { |
|
206 | - return $this->detect_line_endings; |
|
207 | - } |
|
208 | - |
|
209 | - /** |
|
210 | - * Sets the initial line from which start to parse the file |
|
211 | - * |
|
212 | - * @access private |
|
213 | - * @param initial_line int Start parse from this line |
|
214 | - * @return void |
|
215 | - */ |
|
216 | - private function _set_initial_line($initial_line) |
|
217 | - { |
|
218 | - return $this->initial_line = $initial_line; |
|
219 | - } |
|
220 | - |
|
221 | - /** |
|
222 | - * Sets the initial line from which start to parse the file |
|
223 | - * |
|
224 | - * @access public |
|
225 | - * @param initial_line int Start parse from this line |
|
226 | - * @return void |
|
227 | - */ |
|
228 | - public function initial_line($initial_line) |
|
229 | - { |
|
230 | - $this->_set_initial_line($initial_line); |
|
231 | - return $this; |
|
232 | - } |
|
233 | - |
|
234 | - /** |
|
235 | - * Gets the initial line from which start to parse the file |
|
236 | - * |
|
237 | - * @access private |
|
238 | - * @return int |
|
239 | - */ |
|
240 | - private function _get_initial_line() |
|
241 | - { |
|
242 | - return $this->initial_line; |
|
243 | - } |
|
244 | - |
|
245 | - /** |
|
246 | - * Sets the values delimiter |
|
247 | - * |
|
248 | - * @access private |
|
249 | - * @param initial_line string The values delimiter (eg. "," or ";") |
|
250 | - * @return void |
|
251 | - */ |
|
252 | - private function _set_delimiter($delimiter) |
|
253 | - { |
|
254 | - $this->delimiter = $delimiter; |
|
255 | - } |
|
256 | - |
|
257 | - /** |
|
258 | - * Sets the values delimiter |
|
259 | - * |
|
260 | - * @access public |
|
261 | - * @param initial_line string The values delimiter (eg. "," or ";") |
|
262 | - * @return void |
|
263 | - */ |
|
264 | - public function delimiter($delimiter) |
|
265 | - { |
|
266 | - $this->_set_delimiter($delimiter); |
|
267 | - return $this; |
|
268 | - } |
|
269 | - |
|
270 | - /** |
|
271 | - * Gets the values delimiter |
|
272 | - * |
|
273 | - * @access private |
|
274 | - * @return string |
|
275 | - */ |
|
276 | - private function _get_delimiter() |
|
277 | - { |
|
278 | - return $this->delimiter; |
|
279 | - } |
|
280 | - |
|
281 | - /** |
|
282 | - * Sets the filepath of a given CSV file |
|
283 | - * |
|
284 | - * @access private |
|
285 | - * @param filepath string Location of the CSV file |
|
286 | - * @return void |
|
287 | - */ |
|
288 | - private function _set_filepath($filepath) |
|
289 | - { |
|
290 | - $this->filepath = $filepath; |
|
291 | - } |
|
292 | - |
|
293 | - /** |
|
294 | - * Sets the filepath of a given CSV file |
|
295 | - * |
|
296 | - * @access public |
|
297 | - * @param filepath string Location of the CSV file |
|
298 | - * @return void |
|
299 | - */ |
|
300 | - public function filepath($filepath) |
|
301 | - { |
|
302 | - $this->_set_filepath($filepath); |
|
303 | - return $this; |
|
304 | - } |
|
305 | - |
|
306 | - /** |
|
307 | - * Gets the filepath of a given CSV file |
|
308 | - * |
|
309 | - * @access private |
|
310 | - * @return string |
|
311 | - */ |
|
312 | - private function _get_filepath() |
|
313 | - { |
|
314 | - return $this->filepath; |
|
315 | - } |
|
173 | + /** |
|
174 | + * Sets the "detect_line_endings" flag |
|
175 | + * |
|
176 | + * @access private |
|
177 | + * @param detect_line_endings bool The flag bit |
|
178 | + * @return void |
|
179 | + */ |
|
180 | + private function _set_detect_line_endings($detect_line_endings) |
|
181 | + { |
|
182 | + $this->detect_line_endings = $detect_line_endings; |
|
183 | + } |
|
184 | + |
|
185 | + /** |
|
186 | + * Sets the "detect_line_endings" flag |
|
187 | + * |
|
188 | + * @access public |
|
189 | + * @param detect_line_endings bool The flag bit |
|
190 | + * @return void |
|
191 | + */ |
|
192 | + public function detect_line_endings($detect_line_endings) |
|
193 | + { |
|
194 | + $this->_set_detect_line_endings($detect_line_endings); |
|
195 | + return $this; |
|
196 | + } |
|
197 | + |
|
198 | + /** |
|
199 | + * Gets the "detect_line_endings" flag |
|
200 | + * |
|
201 | + * @access private |
|
202 | + * @return bool |
|
203 | + */ |
|
204 | + private function _get_detect_line_endings() |
|
205 | + { |
|
206 | + return $this->detect_line_endings; |
|
207 | + } |
|
208 | + |
|
209 | + /** |
|
210 | + * Sets the initial line from which start to parse the file |
|
211 | + * |
|
212 | + * @access private |
|
213 | + * @param initial_line int Start parse from this line |
|
214 | + * @return void |
|
215 | + */ |
|
216 | + private function _set_initial_line($initial_line) |
|
217 | + { |
|
218 | + return $this->initial_line = $initial_line; |
|
219 | + } |
|
220 | + |
|
221 | + /** |
|
222 | + * Sets the initial line from which start to parse the file |
|
223 | + * |
|
224 | + * @access public |
|
225 | + * @param initial_line int Start parse from this line |
|
226 | + * @return void |
|
227 | + */ |
|
228 | + public function initial_line($initial_line) |
|
229 | + { |
|
230 | + $this->_set_initial_line($initial_line); |
|
231 | + return $this; |
|
232 | + } |
|
233 | + |
|
234 | + /** |
|
235 | + * Gets the initial line from which start to parse the file |
|
236 | + * |
|
237 | + * @access private |
|
238 | + * @return int |
|
239 | + */ |
|
240 | + private function _get_initial_line() |
|
241 | + { |
|
242 | + return $this->initial_line; |
|
243 | + } |
|
244 | + |
|
245 | + /** |
|
246 | + * Sets the values delimiter |
|
247 | + * |
|
248 | + * @access private |
|
249 | + * @param initial_line string The values delimiter (eg. "," or ";") |
|
250 | + * @return void |
|
251 | + */ |
|
252 | + private function _set_delimiter($delimiter) |
|
253 | + { |
|
254 | + $this->delimiter = $delimiter; |
|
255 | + } |
|
256 | + |
|
257 | + /** |
|
258 | + * Sets the values delimiter |
|
259 | + * |
|
260 | + * @access public |
|
261 | + * @param initial_line string The values delimiter (eg. "," or ";") |
|
262 | + * @return void |
|
263 | + */ |
|
264 | + public function delimiter($delimiter) |
|
265 | + { |
|
266 | + $this->_set_delimiter($delimiter); |
|
267 | + return $this; |
|
268 | + } |
|
269 | + |
|
270 | + /** |
|
271 | + * Gets the values delimiter |
|
272 | + * |
|
273 | + * @access private |
|
274 | + * @return string |
|
275 | + */ |
|
276 | + private function _get_delimiter() |
|
277 | + { |
|
278 | + return $this->delimiter; |
|
279 | + } |
|
280 | + |
|
281 | + /** |
|
282 | + * Sets the filepath of a given CSV file |
|
283 | + * |
|
284 | + * @access private |
|
285 | + * @param filepath string Location of the CSV file |
|
286 | + * @return void |
|
287 | + */ |
|
288 | + private function _set_filepath($filepath) |
|
289 | + { |
|
290 | + $this->filepath = $filepath; |
|
291 | + } |
|
292 | + |
|
293 | + /** |
|
294 | + * Sets the filepath of a given CSV file |
|
295 | + * |
|
296 | + * @access public |
|
297 | + * @param filepath string Location of the CSV file |
|
298 | + * @return void |
|
299 | + */ |
|
300 | + public function filepath($filepath) |
|
301 | + { |
|
302 | + $this->_set_filepath($filepath); |
|
303 | + return $this; |
|
304 | + } |
|
305 | + |
|
306 | + /** |
|
307 | + * Gets the filepath of a given CSV file |
|
308 | + * |
|
309 | + * @access private |
|
310 | + * @return string |
|
311 | + */ |
|
312 | + private function _get_filepath() |
|
313 | + { |
|
314 | + return $this->filepath; |
|
315 | + } |
|
316 | 316 | |
317 | 317 | /** |
318 | - * Sets the alternate column headers that will be used when creating the array |
|
319 | - * |
|
320 | - * @access private |
|
321 | - * @param column_headers array Alternate column_headers that will be used instead of first line of CSV |
|
322 | - * @return void |
|
323 | - */ |
|
324 | - private function _set_column_headers($column_headers='') |
|
325 | - { |
|
326 | - if(is_array($column_headers) && !empty($column_headers)) |
|
327 | - { |
|
328 | - $this->column_headers = $column_headers; |
|
329 | - } |
|
330 | - } |
|
331 | - |
|
332 | - /** |
|
333 | - * Sets the alternate column headers that will be used when creating the array |
|
334 | - * |
|
335 | - * @access public |
|
336 | - * @param column_headers array Alternate column_headers that will be used instead of first line of CSV |
|
337 | - * @return void |
|
338 | - */ |
|
339 | - public function column_headers($column_headers) |
|
340 | - { |
|
341 | - $this->_set_column_headers($column_headers); |
|
342 | - return $this; |
|
343 | - } |
|
344 | - |
|
345 | - /** |
|
346 | - * Gets the alternate column headers that will be used when creating the array |
|
347 | - * |
|
348 | - * @access private |
|
349 | - * @return mixed |
|
350 | - */ |
|
351 | - private function _get_column_headers() |
|
352 | - { |
|
353 | - return $this->column_headers; |
|
354 | - } |
|
318 | + * Sets the alternate column headers that will be used when creating the array |
|
319 | + * |
|
320 | + * @access private |
|
321 | + * @param column_headers array Alternate column_headers that will be used instead of first line of CSV |
|
322 | + * @return void |
|
323 | + */ |
|
324 | + private function _set_column_headers($column_headers='') |
|
325 | + { |
|
326 | + if(is_array($column_headers) && !empty($column_headers)) |
|
327 | + { |
|
328 | + $this->column_headers = $column_headers; |
|
329 | + } |
|
330 | + } |
|
331 | + |
|
332 | + /** |
|
333 | + * Sets the alternate column headers that will be used when creating the array |
|
334 | + * |
|
335 | + * @access public |
|
336 | + * @param column_headers array Alternate column_headers that will be used instead of first line of CSV |
|
337 | + * @return void |
|
338 | + */ |
|
339 | + public function column_headers($column_headers) |
|
340 | + { |
|
341 | + $this->_set_column_headers($column_headers); |
|
342 | + return $this; |
|
343 | + } |
|
344 | + |
|
345 | + /** |
|
346 | + * Gets the alternate column headers that will be used when creating the array |
|
347 | + * |
|
348 | + * @access private |
|
349 | + * @return mixed |
|
350 | + */ |
|
351 | + private function _get_column_headers() |
|
352 | + { |
|
353 | + return $this->column_headers; |
|
354 | + } |
|
355 | 355 | |
356 | 356 | /** |
357 | - * Opens the CSV file for parsing |
|
358 | - * |
|
359 | - * @access private |
|
360 | - * @return void |
|
361 | - */ |
|
362 | - private function _get_handle() |
|
363 | - { |
|
364 | - $this->handle = fopen($this->filepath, "r"); |
|
365 | - } |
|
357 | + * Opens the CSV file for parsing |
|
358 | + * |
|
359 | + * @access private |
|
360 | + * @return void |
|
361 | + */ |
|
362 | + private function _get_handle() |
|
363 | + { |
|
364 | + $this->handle = fopen($this->filepath, "r"); |
|
365 | + } |
|
366 | 366 | |
367 | 367 | /** |
368 | - * Closes the CSV file when complete |
|
369 | - * |
|
370 | - * @access private |
|
371 | - * @return array |
|
372 | - */ |
|
373 | - private function _close_csv() |
|
374 | - { |
|
375 | - fclose($this->handle); |
|
376 | - } |
|
368 | + * Closes the CSV file when complete |
|
369 | + * |
|
370 | + * @access private |
|
371 | + * @return array |
|
372 | + */ |
|
373 | + private function _close_csv() |
|
374 | + { |
|
375 | + fclose($this->handle); |
|
376 | + } |
|
377 | 377 | } |
@@ -25,7 +25,7 @@ |
||
25 | 25 | class JsonParser implements ParserInterface |
26 | 26 | { |
27 | 27 | public function parse(string $input): array |
28 | - { |
|
29 | - return json_decode($input, true); |
|
30 | - } |
|
28 | + { |
|
29 | + return json_decode($input, true); |
|
30 | + } |
|
31 | 31 | } |
32 | 32 | \ No newline at end of file |
@@ -12,7 +12,7 @@ discard block |
||
12 | 12 | * ezSQL error strings - mySQLi |
13 | 13 | */ |
14 | 14 | |
15 | - global $ezsql_mysqli_str; |
|
15 | + global $ezsql_mysqli_str; |
|
16 | 16 | |
17 | 17 | $ezsql_mysqli_str = array |
18 | 18 | ( |
@@ -185,9 +185,9 @@ discard block |
||
185 | 185 | $this->select($this->dbname, $this->encoding); |
186 | 186 | } |
187 | 187 | |
188 | - if ( get_magic_quotes_gpc() ) { |
|
188 | + if ( get_magic_quotes_gpc() ) { |
|
189 | 189 | $str = stripslashes($str); |
190 | - } |
|
190 | + } |
|
191 | 191 | |
192 | 192 | return $this->dbh->escape_string($str); |
193 | 193 | } |
@@ -34,39 +34,39 @@ discard block |
||
34 | 34 | } |
35 | 35 | public function getUserKeys() { |
36 | 36 | return array( |
37 | - 'store_url' => $this->getOption('home'), |
|
38 | - 'consumer_key' => $this->getOption('wpt_wc_api_consumer_consumer_key'), |
|
39 | - 'consumer_secret' => $this->getOption('wpt_wc_api_consumer_consumer_secret') |
|
40 | - ); |
|
37 | + 'store_url' => $this->getOption('home'), |
|
38 | + 'consumer_key' => $this->getOption('wpt_wc_api_consumer_consumer_key'), |
|
39 | + 'consumer_secret' => $this->getOption('wpt_wc_api_consumer_consumer_secret') |
|
40 | + ); |
|
41 | 41 | } |
42 | 42 | public function get($endpoint, $params) { |
43 | 43 | if ($this->synched()) { |
44 | 44 | try { |
45 | - // Array of response results. |
|
46 | - $woocommerce = $this->wc_api_connect(); |
|
47 | - $results = $woocommerce->get($endpoint, $params); |
|
48 | - // Example: ['customers' => [[ 'id' => 8, 'created_at' => '2015-05-06T17:43:51Z', 'email' => ... |
|
45 | + // Array of response results. |
|
46 | + $woocommerce = $this->wc_api_connect(); |
|
47 | + $results = $woocommerce->get($endpoint, $params); |
|
48 | + // Example: ['customers' => [[ 'id' => 8, 'created_at' => '2015-05-06T17:43:51Z', 'email' => ... |
|
49 | 49 | |
50 | - // Last request data. |
|
51 | - $lastRequest = $woocommerce->http->getRequest(); |
|
52 | - $lastRequest->getUrl(); // Requested URL (string). |
|
53 | - $lastRequest->getMethod(); // Request method (string). |
|
54 | - $lastRequest->getParameters(); // Request parameters (array). |
|
55 | - $lastRequest->getHeaders(); // Request headers (array). |
|
56 | - $lastRequest->getBody(); // Request body (JSON). |
|
50 | + // Last request data. |
|
51 | + $lastRequest = $woocommerce->http->getRequest(); |
|
52 | + $lastRequest->getUrl(); // Requested URL (string). |
|
53 | + $lastRequest->getMethod(); // Request method (string). |
|
54 | + $lastRequest->getParameters(); // Request parameters (array). |
|
55 | + $lastRequest->getHeaders(); // Request headers (array). |
|
56 | + $lastRequest->getBody(); // Request body (JSON). |
|
57 | 57 | |
58 | - // Last response data. |
|
59 | - $lastResponse = $woocommerce->http->getResponse(); |
|
60 | - $lastResponse->getCode(); // Response code (int). |
|
61 | - $lastResponse->getHeaders(); // Response headers (array). |
|
62 | - $lastResponse->getBody(); // Response body (JSON). |
|
58 | + // Last response data. |
|
59 | + $lastResponse = $woocommerce->http->getResponse(); |
|
60 | + $lastResponse->getCode(); // Response code (int). |
|
61 | + $lastResponse->getHeaders(); // Response headers (array). |
|
62 | + $lastResponse->getBody(); // Response body (JSON). |
|
63 | 63 | |
64 | - return $results; |
|
64 | + return $results; |
|
65 | 65 | |
66 | 66 | } catch (HttpClientException $e) { |
67 | - $e->getMessage(); // Error message. |
|
68 | - $e->getRequest(); // Last request data. |
|
69 | - $e->getResponse(); // Last response data. |
|
67 | + $e->getMessage(); // Error message. |
|
68 | + $e->getRequest(); // Last request data. |
|
69 | + $e->getResponse(); // Last response data. |
|
70 | 70 | } |
71 | 71 | } |
72 | 72 | } |
@@ -131,32 +131,32 @@ discard block |
||
131 | 131 | * @return \Automattic\WooCommerce\Client|bool |
132 | 132 | */ |
133 | 133 | public function wc_api_connect() { |
134 | - static $connection; |
|
134 | + static $connection; |
|
135 | 135 | |
136 | - if ( isset( $connection ) ) { |
|
137 | - return $connection; |
|
138 | - } |
|
136 | + if ( isset( $connection ) ) { |
|
137 | + return $connection; |
|
138 | + } |
|
139 | 139 | |
140 | - $keys = $this->getUserKeys(); |
|
140 | + $keys = $this->getUserKeys(); |
|
141 | 141 | |
142 | - if ( ! $keys ) { |
|
143 | - $connection = false; |
|
142 | + if ( ! $keys ) { |
|
143 | + $connection = false; |
|
144 | 144 | |
145 | - return $connection; |
|
146 | - } |
|
145 | + return $connection; |
|
146 | + } |
|
147 | 147 | |
148 | - $connection = new Client( |
|
149 | - $keys['store_url'], |
|
150 | - $keys['consumer_key'], |
|
151 | - $keys['consumer_secret'], |
|
152 | - array( |
|
153 | - 'wp_api' => true, |
|
154 | - 'version' => 'wc/v2', |
|
155 | - 'verify_ssl' => false, // Allow self-signed certificates (remove for prod) |
|
156 | - ) |
|
157 | - ); |
|
148 | + $connection = new Client( |
|
149 | + $keys['store_url'], |
|
150 | + $keys['consumer_key'], |
|
151 | + $keys['consumer_secret'], |
|
152 | + array( |
|
153 | + 'wp_api' => true, |
|
154 | + 'version' => 'wc/v2', |
|
155 | + 'verify_ssl' => false, // Allow self-signed certificates (remove for prod) |
|
156 | + ) |
|
157 | + ); |
|
158 | 158 | |
159 | - return $connection; |
|
159 | + return $connection; |
|
160 | 160 | } |
161 | 161 | } |
162 | 162 |