@@ -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 |
@@ -83,12 +83,10 @@ |
||
83 | 83 | if(filter_var($client, FILTER_VALIDATE_IP)) |
84 | 84 | { |
85 | 85 | $ip = $client; |
86 | - } |
|
87 | - elseif(filter_var($forward, FILTER_VALIDATE_IP)) |
|
86 | + } elseif(filter_var($forward, FILTER_VALIDATE_IP)) |
|
88 | 87 | { |
89 | 88 | $ip = $forward; |
90 | - } |
|
91 | - else |
|
89 | + } else |
|
92 | 90 | { |
93 | 91 | $ip = $remote; |
94 | 92 | } |
@@ -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 | } |
@@ -52,8 +52,7 @@ discard block |
||
52 | 52 | if(! $filepath) |
53 | 53 | { |
54 | 54 | $filepath = $this->_get_filepath(); |
55 | - } |
|
56 | - else |
|
55 | + } else |
|
57 | 56 | { |
58 | 57 | // If filepath provided, set it |
59 | 58 | $this->_set_filepath($filepath); |
@@ -69,8 +68,7 @@ discard block |
||
69 | 68 | if(! $detect_line_endings) |
70 | 69 | { |
71 | 70 | $detect_line_endings = $this->_get_detect_line_endings(); |
72 | - } |
|
73 | - else |
|
71 | + } else |
|
74 | 72 | { |
75 | 73 | // If detect_line_endings provided, set it |
76 | 74 | $this->_set_detect_line_endings($detect_line_endings); |
@@ -86,8 +84,7 @@ discard block |
||
86 | 84 | if(! $initial_line) |
87 | 85 | { |
88 | 86 | $initial_line = $this->_get_initial_line(); |
89 | - } |
|
90 | - else |
|
87 | + } else |
|
91 | 88 | { |
92 | 89 | $this->_set_initial_line($initial_line); |
93 | 90 | } |
@@ -96,8 +93,7 @@ discard block |
||
96 | 93 | if(! $delimiter) |
97 | 94 | { |
98 | 95 | $delimiter = $this->_get_delimiter(); |
99 | - } |
|
100 | - else |
|
96 | + } else |
|
101 | 97 | { |
102 | 98 | // If delimiter provided, set it |
103 | 99 | $this->_set_delimiter($delimiter); |
@@ -107,8 +103,7 @@ discard block |
||
107 | 103 | if(! $column_headers) |
108 | 104 | { |
109 | 105 | $column_headers = $this->_get_column_headers(); |
110 | - } |
|
111 | - else |
|
106 | + } else |
|
112 | 107 | { |
113 | 108 | // If column headers provided, set them |
114 | 109 | $this->_set_column_headers($column_headers); |
@@ -139,22 +134,22 @@ discard block |
||
139 | 134 | { |
140 | 135 | $column_headers[$key] = trim($value); |
141 | 136 | } |
142 | - } |
|
143 | - else // Parse first row for column_headers to use |
|
137 | + } else // Parse first row for column_headers to use |
|
144 | 138 | { |
145 | 139 | foreach ($data as $key => $value) |
146 | 140 | { |
147 | 141 | $column_headers[$key] = trim($value); |
148 | 142 | } |
149 | 143 | } |
150 | - } |
|
151 | - else |
|
144 | + } else |
|
152 | 145 | { |
153 | 146 | $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 |
|
147 | + foreach($column_headers as $key => $value) { |
|
148 | + // assumes there are as many columns as their are title columns |
|
155 | 149 | { |
156 | 150 | $result[$new_row][$value] = utf8_encode(trim($data[$key])); |
157 | 151 | } |
152 | + } |
|
158 | 153 | } |
159 | 154 | |
160 | 155 | unset($data); |
@@ -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 |
@@ -234,8 +234,7 @@ discard block |
||
234 | 234 | if ( $output == OBJECT ) |
235 | 235 | { |
236 | 236 | return $this->last_result; |
237 | - } |
|
238 | - elseif ( $output == ARRAY_A || $output == ARRAY_N ) |
|
237 | + } elseif ( $output == ARRAY_A || $output == ARRAY_N ) |
|
239 | 238 | { |
240 | 239 | if ( $this->last_result ) |
241 | 240 | { |
@@ -254,8 +253,7 @@ discard block |
||
254 | 253 | } |
255 | 254 | |
256 | 255 | return $new_array; |
257 | - } |
|
258 | - else |
|
256 | + } else |
|
259 | 257 | { |
260 | 258 | return array(); |
261 | 259 | } |
@@ -282,8 +280,7 @@ discard block |
||
282 | 280 | $i++; |
283 | 281 | } |
284 | 282 | return $new_array; |
285 | - } |
|
286 | - else |
|
283 | + } else |
|
287 | 284 | { |
288 | 285 | return $this->col_info[$col_offset]->{$info_type}; |
289 | 286 | } |
@@ -309,8 +306,7 @@ discard block |
||
309 | 306 | { |
310 | 307 | $this->register_error("Could not open cache dir: $this->cache_dir"); |
311 | 308 | $this->show_errors ? trigger_error("Could not open cache dir: $this->cache_dir",E_USER_WARNING) : null; |
312 | - } |
|
313 | - else |
|
309 | + } else |
|
314 | 310 | { |
315 | 311 | // Cache all result values |
316 | 312 | $result_cache = array |
@@ -321,8 +317,9 @@ discard block |
||
321 | 317 | 'return_value' => $this->num_rows, |
322 | 318 | ); |
323 | 319 | file_put_contents($cache_file, serialize($result_cache)); |
324 | - if( file_exists($cache_file . ".updating") ) |
|
325 | - unlink($cache_file . ".updating"); |
|
320 | + if( file_exists($cache_file . ".updating") ) { |
|
321 | + unlink($cache_file . ".updating"); |
|
322 | + } |
|
326 | 323 | } |
327 | 324 | } |
328 | 325 | |
@@ -346,8 +343,7 @@ discard block |
||
346 | 343 | !(file_exists($cache_file . ".updating") && (time() - filemtime($cache_file . ".updating") < 60)) ) |
347 | 344 | { |
348 | 345 | touch($cache_file . ".updating"); // Show that we in the process of updating the cache |
349 | - } |
|
350 | - else |
|
346 | + } else |
|
351 | 347 | { |
352 | 348 | $result_cache = unserialize(file_get_contents($cache_file)); |
353 | 349 | |
@@ -603,10 +599,12 @@ discard block |
||
603 | 599 | $sql = array(); |
604 | 600 | foreach ( $params as $field => $val ) |
605 | 601 | { |
606 | - if ( $val === 'true' || $val === true ) |
|
607 | - $val = 1; |
|
608 | - if ( $val === 'false' || $val === false ) |
|
609 | - $val = 0; |
|
602 | + if ( $val === 'true' || $val === true ) { |
|
603 | + $val = 1; |
|
604 | + } |
|
605 | + if ( $val === 'false' || $val === false ) { |
|
606 | + $val = 0; |
|
607 | + } |
|
610 | 608 | |
611 | 609 | switch( $val ){ |
612 | 610 | case 'NOW()' : |
@@ -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 | } |
@@ -27,8 +27,12 @@ discard block |
||
27 | 27 | * ezSQL Database specific class - mySQLi |
28 | 28 | */ |
29 | 29 | |
30 | - if ( ! function_exists ('mysqli_connect') ) die('<b>Fatal Error:</b> ezSQL_mysql requires mySQLi Lib to be compiled and or linked in to the PHP engine'); |
|
31 | - if ( ! class_exists ('ezSQLcore') ) die('<b>Fatal Error:</b> ezSQL_mysql requires ezSQLcore (ez_sql_core.php) to be included/loaded before it can be used'); |
|
30 | + if ( ! function_exists ('mysqli_connect') ) { |
|
31 | + die('<b>Fatal Error:</b> ezSQL_mysql requires mySQLi Lib to be compiled and or linked in to the PHP engine'); |
|
32 | + } |
|
33 | + if ( ! class_exists ('ezSQLcore') ) { |
|
34 | + die('<b>Fatal Error:</b> ezSQL_mysql requires ezSQLcore (ez_sql_core.php) to be included/loaded before it can be used'); |
|
35 | + } |
|
32 | 36 | |
33 | 37 | class ezSQL_mysqli extends ezSQLcore |
34 | 38 | { |
@@ -65,7 +69,9 @@ discard block |
||
65 | 69 | $return_val = false; |
66 | 70 | if ( ! $this->connect($dbuser, $dbpassword, $dbhost, $dbport) ) ; |
67 | 71 | else if ( ! $this->select($dbname,$encoding) ) ; |
68 | - else $return_val = true; |
|
72 | + else { |
|
73 | + $return_val = true; |
|
74 | + } |
|
69 | 75 | return $return_val; |
70 | 76 | } |
71 | 77 | |
@@ -100,8 +106,7 @@ discard block |
||
100 | 106 | { |
101 | 107 | $this->register_error($ezsql_mysqli_str[2].' in '.__FILE__.' on line '.__LINE__); |
102 | 108 | $this->show_errors ? trigger_error($ezsql_mysqli_str[2],E_USER_WARNING) : null; |
103 | - } |
|
104 | - else |
|
109 | + } else |
|
105 | 110 | { |
106 | 111 | $this->dbuser = $dbuser; |
107 | 112 | $this->dbpassword = $dbpassword; |
@@ -142,13 +147,13 @@ discard block |
||
142 | 147 | else if ( !@$this->dbh->select_db($dbname) ) |
143 | 148 | { |
144 | 149 | // Try to get error supplied by mysql if not use our own |
145 | - if ( !$str = @$this->dbh->error) |
|
146 | - $str = $ezsql_mysqli_str[5]; |
|
150 | + if ( !$str = @$this->dbh->error) { |
|
151 | + $str = $ezsql_mysqli_str[5]; |
|
152 | + } |
|
147 | 153 | |
148 | 154 | $this->register_error($str.' in '.__FILE__.' on line '.__LINE__); |
149 | 155 | $this->show_errors ? trigger_error($str,E_USER_WARNING) : null; |
150 | - } |
|
151 | - else |
|
156 | + } else |
|
152 | 157 | { |
153 | 158 | $this->dbname = $dbname; |
154 | 159 | if($encoding!='') |
@@ -258,8 +263,9 @@ discard block |
||
258 | 263 | $this->connect($this->dbuser, $this->dbpassword, $this->dbhost, $this->dbport); |
259 | 264 | $this->select($this->dbname,$this->encoding); |
260 | 265 | // No existing connection at this point means the server is unreachable |
261 | - if ( ! isset($this->dbh) || ! $this->dbh || $this->dbh->connect_errno ) |
|
262 | - return false; |
|
266 | + if ( ! isset($this->dbh) || ! $this->dbh || $this->dbh->connect_errno ) { |
|
267 | + return false; |
|
268 | + } |
|
263 | 269 | } |
264 | 270 | |
265 | 271 | // Perform the query via std mysql_query function.. |
@@ -391,8 +397,7 @@ discard block |
||
391 | 397 | $this->s_params = array(); |
392 | 398 | |
393 | 399 | return $this->query($query); |
394 | - } |
|
395 | - else |
|
400 | + } else |
|
396 | 401 | { |
397 | 402 | return NULL; |
398 | 403 | } |