@@ -121,15 +121,15 @@ |
||
121 | 121 | $this->appendRow(",\n"); |
122 | 122 | } |
123 | 123 | |
124 | - $item = array_reduce($item, function ($outCell, $currentCell) { |
|
124 | + $item = array_reduce($item, function($outCell, $currentCell) { |
|
125 | 125 | if (is_null($currentCell)) { |
126 | 126 | $outCell[] = 'null'; |
127 | 127 | |
128 | 128 | return $outCell; |
129 | 129 | } |
130 | 130 | //escape sql string |
131 | - $search = ['\\', "\x00", "\n", "\r", "'", '"', "\x1a"]; |
|
132 | - $replace = ['\\\\','\\0','\\n', '\\r', "\'", '\"', '\\Z']; |
|
131 | + $search = ['\\', "\x00", "\n", "\r", "'", '"', "\x1a"]; |
|
132 | + $replace = ['\\\\', '\\0', '\\n', '\\r', "\'", '\"', '\\Z']; |
|
133 | 133 | $outCell[] = '"' . str_replace($search, $replace, $currentCell) . '"'; |
134 | 134 | |
135 | 135 | return $outCell; |
@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | 'header' => true, |
50 | 50 | 'delimiter' => "\t", |
51 | 51 | ]; |
52 | - foreach (['columns','delimiter','enclosure','header','replace_file'] as $option) { |
|
52 | + foreach (['columns', 'delimiter', 'enclosure', 'header', 'replace_file'] as $option) { |
|
53 | 53 | if (array_key_exists($option, $options)) { |
54 | 54 | $opts[$option] = $options[$option]; |
55 | 55 | } |
@@ -98,7 +98,7 @@ discard block |
||
98 | 98 | $rowsToIgnore = $this->options['header'] ? 1 : 0; |
99 | 99 | $headers = '(' . implode(', ', $this->headers) . ')'; |
100 | 100 | |
101 | - $delimiter = str_replace(["\t","\n","\r"], ['\\t','\\n','\\r'], $this->options['delimiter']); |
|
101 | + $delimiter = str_replace(["\t", "\n", "\r"], ['\\t', '\\n', '\\r'], $this->options['delimiter']); |
|
102 | 102 | $enclosure = $this->options['enclosure']; |
103 | 103 | |
104 | 104 | $createTableSql = null; |
@@ -108,7 +108,7 @@ discard block |
||
108 | 108 | |
109 | 109 | $autoIncrementField = $this->options['autoincrement_field'] ? $this->options['autoincrement_field'] . ' int auto_increment not null, ' : ''; |
110 | 110 | $primaryKeyField = $this->options['autoincrement_field'] ? ', primary key (' . $this->options['autoincrement_field'] . ')' : ''; |
111 | - $createTableSql = sprintf('DROP TABLE IF EXISTS %s;CREATE TABLE %s (%s%s%s);', $this->tableName, $this->tableName, $autoIncrementField, implode(', ', array_map(function ($value) { |
|
111 | + $createTableSql = sprintf('DROP TABLE IF EXISTS %s;CREATE TABLE %s (%s%s%s);', $this->tableName, $this->tableName, $autoIncrementField, implode(', ', array_map(function($value) { |
|
112 | 112 | return $value . ' text'; |
113 | 113 | }, $columnNames)), $primaryKeyField); |
114 | 114 | } |
@@ -46,7 +46,7 @@ |
||
46 | 46 | |
47 | 47 | while (($data = $this->readCurrentRow()) != false) { |
48 | 48 | //skip empty rows |
49 | - if($data == [null]){ |
|
49 | + if ($data == [null]) { |
|
50 | 50 | continue; |
51 | 51 | } |
52 | 52 | if ($headers) { |
@@ -6,7 +6,7 @@ |
||
6 | 6 | * Class LowerThanEqualFilter |
7 | 7 | * @package Jackal\Copycat\Filter\ValueFilter |
8 | 8 | */ |
9 | -class LowerThanEqualFilter extends AbstractCompareFilter{ |
|
9 | +class LowerThanEqualFilter extends AbstractCompareFilter { |
|
10 | 10 | |
11 | 11 | protected function getComparison() |
12 | 12 | { |
@@ -6,7 +6,7 @@ |
||
6 | 6 | * Class NotBlankFilter |
7 | 7 | * @package Jackal\Copycat\Filter\ValueFilter |
8 | 8 | */ |
9 | -class NotBlankFilter extends EqualFilter{ |
|
9 | +class NotBlankFilter extends EqualFilter { |
|
10 | 10 | public function __construct($fieldName) |
11 | 11 | { |
12 | 12 | parent::__construct($fieldName, ''); |
@@ -6,7 +6,7 @@ |
||
6 | 6 | * Class GreaterThanEqualFilter |
7 | 7 | * @package Jackal\Copycat\Filter\ValueFilter |
8 | 8 | */ |
9 | -class GreaterThanEqualFilter extends AbstractCompareFilter{ |
|
9 | +class GreaterThanEqualFilter extends AbstractCompareFilter { |
|
10 | 10 | |
11 | 11 | protected function getComparison() |
12 | 12 | { |
@@ -37,17 +37,17 @@ discard block |
||
37 | 37 | */ |
38 | 38 | public function __invoke($value) |
39 | 39 | { |
40 | - return $this->applyComparison($value[$this->fieldName], $this->comparedValue,$this->getComparison()); |
|
40 | + return $this->applyComparison($value[$this->fieldName], $this->comparedValue, $this->getComparison()); |
|
41 | 41 | } |
42 | 42 | |
43 | - protected function applyComparison($value1,$value2,$comparison){ |
|
43 | + protected function applyComparison($value1, $value2, $comparison) { |
|
44 | 44 | |
45 | 45 | $value1 = $this->parseAsString($value1); |
46 | 46 | $value2 = $this->parseAsString($value2); |
47 | 47 | |
48 | - switch ($comparison){ |
|
48 | + switch ($comparison) { |
|
49 | 49 | case self::COMPARISON_EQ:{ |
50 | - if($value1 === null and $value2 === ''){ |
|
50 | + if ($value1 === null and $value2 === '') { |
|
51 | 51 | return true; |
52 | 52 | } |
53 | 53 | return $value1 === $value2; |
@@ -75,12 +75,12 @@ discard block |
||
75 | 75 | * @param mixed $value |
76 | 76 | * @return string|null |
77 | 77 | */ |
78 | - protected function parseAsString($value){ |
|
78 | + protected function parseAsString($value) { |
|
79 | 79 | |
80 | - if($value === null){ |
|
80 | + if ($value === null) { |
|
81 | 81 | return null; |
82 | 82 | } |
83 | - if(is_scalar($value)){ |
|
83 | + if (is_scalar($value)) { |
|
84 | 84 | return $value; |
85 | 85 | } |
86 | 86 | |
@@ -88,8 +88,8 @@ discard block |
||
88 | 88 | return $value->format('Y-m-d H:i:s'); |
89 | 89 | } |
90 | 90 | |
91 | - if(is_object($value) and method_exists($value,'__toString')){ |
|
92 | - return (string)$value; |
|
91 | + if (is_object($value) and method_exists($value, '__toString')) { |
|
92 | + return (string) $value; |
|
93 | 93 | } |
94 | 94 | |
95 | 95 | throw new \RuntimeException('Cannot parse filter value'); |
@@ -8,7 +8,7 @@ |
||
8 | 8 | * Class GreaterThanFilter |
9 | 9 | * @package Jackal\Copycat\Filter\ValueFilter |
10 | 10 | */ |
11 | -class GreaterThanFilter extends AbstractCompareFilter{ |
|
11 | +class GreaterThanFilter extends AbstractCompareFilter { |
|
12 | 12 | |
13 | 13 | protected function getComparison() |
14 | 14 | { |
@@ -16,7 +16,7 @@ |
||
16 | 16 | { |
17 | 17 | $object = @unserialize($value[$this->fieldName]); |
18 | 18 | |
19 | - if($object === false and $value[$this->fieldName] !== serialize(false)){ |
|
19 | + if ($object === false and $value[$this->fieldName] !== serialize(false)) { |
|
20 | 20 | throw new \RuntimeException('Error converting string to object.'); |
21 | 21 | } |
22 | 22 | $value[$this->fieldName] = $object; |