@@ -20,21 +20,21 @@ discard block |
||
| 20 | 20 | /** |
| 21 | 21 | * @var array |
| 22 | 22 | */ |
| 23 | - private $degenerations=[]; |
|
| 23 | + private $degenerations = []; |
|
| 24 | 24 | |
| 25 | 25 | /** |
| 26 | 26 | * Query constructor. |
| 27 | 27 | * @param string $sql |
| 28 | 28 | * @param array $degenerations |
| 29 | 29 | */ |
| 30 | - public function __construct($sql,$degenerations=[]) |
|
| 30 | + public function __construct($sql, $degenerations = []) |
|
| 31 | 31 | { |
| 32 | 32 | if (!trim($sql)) |
| 33 | 33 | { |
| 34 | 34 | throw new QueryException('Empty Query'); |
| 35 | 35 | } |
| 36 | 36 | $this->sql = $sql; |
| 37 | - $this->degenerations=$degenerations; |
|
| 37 | + $this->degenerations = $degenerations; |
|
| 38 | 38 | } |
| 39 | 39 | |
| 40 | 40 | /** |
@@ -50,17 +50,17 @@ discard block |
||
| 50 | 50 | { |
| 51 | 51 | // FORMAT\s(\w)*$ |
| 52 | 52 | if (null === $this->format) return false; |
| 53 | - $supportFormats= |
|
| 53 | + $supportFormats = |
|
| 54 | 54 | "FORMAT\\s+TSV|FORMAT\\s+TSVRaw|FORMAT\\s+TSVWithNames|FORMAT\\s+TSVWithNamesAndTypes|FORMAT\\s+Vertical|FORMAT\\s+JSONCompact|FORMAT\\s+JSONEachRow|FORMAT\\s+TSKV|FORMAT\\s+TabSeparatedWithNames|FORMAT\\s+TabSeparatedWithNamesAndTypes|FORMAT\\s+TabSeparatedRaw|FORMAT\\s+BlockTabSeparated|FORMAT\\s+CSVWithNames|FORMAT\\s+CSV|FORMAT\\s+JSON|FORMAT\\s+TabSeparated"; |
| 55 | 55 | |
| 56 | - $matches=[]; |
|
| 57 | - if (preg_match_all('%('.$supportFormats.')%ius',$this->sql,$matches)){ |
|
| 56 | + $matches = []; |
|
| 57 | + if (preg_match_all('%(' . $supportFormats . ')%ius', $this->sql, $matches)) { |
|
| 58 | 58 | |
| 59 | 59 | // skip add "format json" |
| 60 | 60 | if (isset($matches[0])) |
| 61 | 61 | { |
| 62 | 62 | |
| 63 | - $this->format=trim(str_ireplace('format','',$matches[0][0])); |
|
| 63 | + $this->format = trim(str_ireplace('format', '', $matches[0][0])); |
|
| 64 | 64 | |
| 65 | 65 | } |
| 66 | 66 | } |
@@ -95,7 +95,7 @@ discard block |
||
| 95 | 95 | foreach ($this->degenerations as $degeneration) |
| 96 | 96 | { |
| 97 | 97 | if ($degeneration instanceof Degeneration) { |
| 98 | - $this->sql=$degeneration->process($this->sql); |
|
| 98 | + $this->sql = $degeneration->process($this->sql); |
|
| 99 | 99 | } |
| 100 | 100 | } |
| 101 | 101 | } |
@@ -13,7 +13,7 @@ discard block |
||
| 13 | 13 | const FORMAT_TabSeparatedWithNames = 'TabSeparatedWithNames'; |
| 14 | 14 | const FORMAT_CSV = 'CSV'; |
| 15 | 15 | |
| 16 | - private $support_format=['TabSeparated','TabSeparatedWithNames','CSV']; |
|
| 16 | + private $support_format = ['TabSeparated', 'TabSeparatedWithNames', 'CSV']; |
|
| 17 | 17 | /** |
| 18 | 18 | * @var string |
| 19 | 19 | */ |
@@ -22,19 +22,19 @@ discard block |
||
| 22 | 22 | /** |
| 23 | 23 | * @var string |
| 24 | 24 | */ |
| 25 | - private $format='CSV'; |
|
| 25 | + private $format = 'CSV'; |
|
| 26 | 26 | |
| 27 | 27 | /** |
| 28 | 28 | * @var bool |
| 29 | 29 | */ |
| 30 | - private $gzip=false; |
|
| 30 | + private $gzip = false; |
|
| 31 | 31 | /** |
| 32 | 32 | * WriteToFile constructor. |
| 33 | 33 | * @param string $file_name |
| 34 | 34 | * @param bool $overwrite |
| 35 | 35 | * @param null $format |
| 36 | 36 | */ |
| 37 | - public function __construct($file_name,$overwrite=true,$format=null) { |
|
| 37 | + public function __construct($file_name, $overwrite = true, $format = null) { |
|
| 38 | 38 | |
| 39 | 39 | |
| 40 | 40 | if (!$file_name) |
@@ -53,7 +53,7 @@ discard block |
||
| 53 | 53 | throw new QueryException('Can`t delete: ' . $file_name); |
| 54 | 54 | } |
| 55 | 55 | } |
| 56 | - $dir=dirname($file_name); |
|
| 56 | + $dir = dirname($file_name); |
|
| 57 | 57 | if (!is_writable($dir)) |
| 58 | 58 | { |
| 59 | 59 | throw new QueryException('Can`t writable dir: ' . $dir); |
@@ -62,7 +62,7 @@ discard block |
||
| 62 | 62 | { |
| 63 | 63 | $this->setFormat($format); |
| 64 | 64 | } |
| 65 | - $this->file_name=$file_name; |
|
| 65 | + $this->file_name = $file_name; |
|
| 66 | 66 | } |
| 67 | 67 | |
| 68 | 68 | /** |
@@ -78,7 +78,7 @@ discard block |
||
| 78 | 78 | */ |
| 79 | 79 | public function setGzip($flag) |
| 80 | 80 | { |
| 81 | - $this->gzip=$flag; |
|
| 81 | + $this->gzip = $flag; |
|
| 82 | 82 | } |
| 83 | 83 | |
| 84 | 84 | /** |
@@ -86,11 +86,11 @@ discard block |
||
| 86 | 86 | */ |
| 87 | 87 | public function setFormat($format) |
| 88 | 88 | { |
| 89 | - if (!in_array($format,$this->support_format)) |
|
| 89 | + if (!in_array($format, $this->support_format)) |
|
| 90 | 90 | { |
| 91 | 91 | throw new QueryException('Unsupport format: ' . $format); |
| 92 | 92 | } |
| 93 | - $this->format=$format; |
|
| 93 | + $this->format = $format; |
|
| 94 | 94 | } |
| 95 | 95 | /** |
| 96 | 96 | * @return int |