@@ -82,7 +82,7 @@ |
||
82 | 82 | * @return array |
83 | 83 | */ |
84 | 84 | protected function _tableArray() { |
85 | - return include dirname(dirname(__DIR__)). '/Config/tables.config.php'; |
|
85 | + return include dirname(dirname(__DIR__)).'/Config/tables.config.php'; |
|
86 | 86 | } |
87 | 87 | protected function isValidQueryBuilder($builder) { |
88 | 88 | if ( ! $builder instanceof QueryInterface) { |
@@ -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 |
@@ -80,11 +80,11 @@ |
||
80 | 80 | $forward = @$_SERVER['HTTP_X_FORWARDED_FOR']; |
81 | 81 | $remote = $_SERVER['REMOTE_ADDR']; |
82 | 82 | |
83 | - if(filter_var($client, FILTER_VALIDATE_IP)) |
|
83 | + if (filter_var($client, FILTER_VALIDATE_IP)) |
|
84 | 84 | { |
85 | 85 | $ip = $client; |
86 | 86 | } |
87 | - elseif(filter_var($forward, FILTER_VALIDATE_IP)) |
|
87 | + elseif (filter_var($forward, FILTER_VALIDATE_IP)) |
|
88 | 88 | { |
89 | 89 | $ip = $forward; |
90 | 90 | } |
@@ -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 | } |
@@ -43,13 +43,13 @@ discard block |
||
43 | 43 | * @param delimiter string The values delimiter (e.g. ";" or ","). |
44 | 44 | * @return array |
45 | 45 | */ |
46 | - public function parse($filepath=FALSE, $column_headers=FALSE, $detect_line_endings=FALSE, $initial_line=FALSE, $delimiter=FALSE) |
|
46 | + public function parse($filepath = FALSE, $column_headers = FALSE, $detect_line_endings = FALSE, $initial_line = FALSE, $delimiter = FALSE) |
|
47 | 47 | { |
48 | 48 | // Raise memory limit (for big files) |
49 | 49 | ini_set('memory_limit', '128M'); |
50 | 50 | |
51 | 51 | // File path |
52 | - if(! $filepath) |
|
52 | + if ( ! $filepath) |
|
53 | 53 | { |
54 | 54 | $filepath = $this->_get_filepath(); |
55 | 55 | } |
@@ -60,13 +60,13 @@ discard block |
||
60 | 60 | } |
61 | 61 | |
62 | 62 | // If file doesn't exists, return false |
63 | - if(! file_exists($filepath)) |
|
63 | + if ( ! file_exists($filepath)) |
|
64 | 64 | { |
65 | 65 | return FALSE; |
66 | 66 | } |
67 | 67 | |
68 | 68 | // auto detect row endings |
69 | - if(! $detect_line_endings) |
|
69 | + if ( ! $detect_line_endings) |
|
70 | 70 | { |
71 | 71 | $detect_line_endings = $this->_get_detect_line_endings(); |
72 | 72 | } |
@@ -77,13 +77,13 @@ discard block |
||
77 | 77 | } |
78 | 78 | |
79 | 79 | // If true, auto detect row endings |
80 | - if($detect_line_endings) |
|
80 | + if ($detect_line_endings) |
|
81 | 81 | { |
82 | 82 | ini_set("auto_detect_line_endings", TRUE); |
83 | 83 | } |
84 | 84 | |
85 | 85 | // Parse from this line on |
86 | - if(! $initial_line) |
|
86 | + if ( ! $initial_line) |
|
87 | 87 | { |
88 | 88 | $initial_line = $this->_get_initial_line(); |
89 | 89 | } |
@@ -93,7 +93,7 @@ discard block |
||
93 | 93 | } |
94 | 94 | |
95 | 95 | // Delimiter |
96 | - if(! $delimiter) |
|
96 | + if ( ! $delimiter) |
|
97 | 97 | { |
98 | 98 | $delimiter = $this->_get_delimiter(); |
99 | 99 | } |
@@ -104,7 +104,7 @@ discard block |
||
104 | 104 | } |
105 | 105 | |
106 | 106 | // Column headers |
107 | - if(! $column_headers) |
|
107 | + if ( ! $column_headers) |
|
108 | 108 | { |
109 | 109 | $column_headers = $this->_get_column_headers(); |
110 | 110 | } |
@@ -123,17 +123,17 @@ discard block |
||
123 | 123 | { |
124 | 124 | if ($data[0] != NULL) |
125 | 125 | { |
126 | - if($row < $this->initial_line) |
|
126 | + if ($row < $this->initial_line) |
|
127 | 127 | { |
128 | 128 | $row++; |
129 | 129 | continue; |
130 | 130 | } |
131 | 131 | |
132 | 132 | // If first row, parse for column_headers |
133 | - if($row == $this->initial_line) |
|
133 | + if ($row == $this->initial_line) |
|
134 | 134 | { |
135 | 135 | // If column_headers already provided, use them |
136 | - if($this->column_headers) |
|
136 | + if ($this->column_headers) |
|
137 | 137 | { |
138 | 138 | foreach ($this->column_headers as $key => $value) |
139 | 139 | { |
@@ -151,7 +151,7 @@ discard block |
||
151 | 151 | else |
152 | 152 | { |
153 | 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 |
|
154 | + foreach ($column_headers as $key => $value) // assumes there are as many columns as their are title columns |
|
155 | 155 | { |
156 | 156 | $result[$new_row][$value] = utf8_encode(trim($data[$key])); |
157 | 157 | } |
@@ -321,9 +321,9 @@ discard block |
||
321 | 321 | * @param column_headers array Alternate column_headers that will be used instead of first line of CSV |
322 | 322 | * @return void |
323 | 323 | */ |
324 | - private function _set_column_headers($column_headers='') |
|
324 | + private function _set_column_headers($column_headers = '') |
|
325 | 325 | { |
326 | - if(is_array($column_headers) && !empty($column_headers)) |
|
326 | + if (is_array($column_headers) && ! empty($column_headers)) |
|
327 | 327 | { |
328 | 328 | $this->column_headers = $column_headers; |
329 | 329 | } |
@@ -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 |
@@ -28,7 +28,7 @@ |
||
28 | 28 | $this->db = $this->__connect(); |
29 | 29 | } |
30 | 30 | public function getConfig() { |
31 | - return include dirname(dirname(__DIR__)). '/Config/'.$this->cms.'.config.php'; |
|
31 | + return include dirname(dirname(__DIR__)).'/Config/'.$this->cms.'.config.php'; |
|
32 | 32 | } |
33 | 33 | private function __connect() { |
34 | 34 | $config = $this->getConfig(); |