| 1 | <?php |
||
|
0 ignored issues
–
show
introduced
by
Loading history...
|
|||
| 2 | |||
| 3 | namespace ClickHouseDB\Quote; |
||
| 4 | |||
| 5 | class FormatLine |
||
| 6 | { |
||
| 7 | /** |
||
|
0 ignored issues
–
show
|
|||
| 8 | * |
||
| 9 | * @var array |
||
|
0 ignored issues
–
show
|
|||
| 10 | */ |
||
| 11 | private static $strict = []; |
||
| 12 | |||
| 13 | /** |
||
| 14 | * Format |
||
| 15 | * |
||
| 16 | * @param string $format |
||
|
0 ignored issues
–
show
|
|||
| 17 | * @return StrictQuoteLine |
||
| 18 | */ |
||
| 19 | 12 | public static function strictQuote($format) |
|
|
0 ignored issues
–
show
|
|||
| 20 | { |
||
| 21 | 12 | if (empty(self::$strict[$format])) |
|
|
0 ignored issues
–
show
|
|||
| 22 | { |
||
| 23 | 2 | self::$strict[$format] = new StrictQuoteLine($format); |
|
| 24 | } |
||
| 25 | 12 | return self::$strict[$format]; |
|
|
0 ignored issues
–
show
|
|||
| 26 | } |
||
| 27 | |||
| 28 | /** |
||
| 29 | * Array in a string for a query Insert |
||
| 30 | * |
||
| 31 | * @param mixed[] $row |
||
|
0 ignored issues
–
show
|
|||
| 32 | * @param bool $skipEncode |
||
|
0 ignored issues
–
show
|
|||
| 33 | * @return string |
||
| 34 | */ |
||
| 35 | 12 | public static function Insert(array $row,bool $skipEncode=false) |
|
|
0 ignored issues
–
show
|
|||
| 36 | { |
||
| 37 | 12 | return self::strictQuote('Insert')->quoteRow($row,$skipEncode); |
|
| 38 | } |
||
| 39 | |||
| 40 | /** |
||
| 41 | * Array to TSV |
||
| 42 | * |
||
| 43 | * @param array $row |
||
|
0 ignored issues
–
show
|
|||
| 44 | * @return string |
||
| 45 | */ |
||
| 46 | 1 | public static function TSV(Array $row) |
|
|
0 ignored issues
–
show
|
|||
| 47 | { |
||
| 48 | 1 | return self::strictQuote('TSV')->quoteRow($row); |
|
| 49 | } |
||
| 50 | |||
| 51 | /** |
||
| 52 | * Array to CSV |
||
| 53 | * |
||
| 54 | * @param array $row |
||
|
0 ignored issues
–
show
|
|||
| 55 | * @return string |
||
| 56 | */ |
||
| 57 | 1 | public static function CSV(Array $row) |
|
|
0 ignored issues
–
show
|
|||
| 58 | { |
||
| 59 | 1 | return self::strictQuote('CSV')->quoteRow($row); |
|
| 60 | } |
||
| 61 | } |
||
| 62 |