| Conditions | 9 |
| Paths | 18 |
| Total Lines | 31 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 20 |
| CRAP Score | 9 |
| Changes | 0 | ||
| 1 | <?php |
||
| 7 | 102 | public function convert($from) |
|
| 8 | { |
||
| 9 | 102 | $result = []; |
|
| 10 | 102 | if ('table' === $from[0]['expr_type']) { |
|
| 11 | 102 | $value = $this->getValueWithoutQuotes($from[0], 'table'); |
|
| 12 | 102 | if (isset($from[0]['alias']) && is_array($from[0]['alias'])) { |
|
| 13 | 3 | $value .= ' AS '.$this->getValueWithoutQuotes($from[0]['alias'], 'name'); |
|
| 14 | } |
||
| 15 | 102 | $result[] = $this->format('table', [$value]); |
|
| 16 | } |
||
| 17 | 102 | unset($from[0]); |
|
| 18 | 102 | foreach ($from as $item) { |
|
| 19 | 15 | if (in_array($item['join_type'], ['LEFT', 'RIGHT'], true)) { |
|
| 20 | 15 | $table = $this->getValueWithoutQuotes($item, 'table'); |
|
| 21 | 15 | if (isset($item['alias']) && is_array($item['alias'])) { |
|
| 22 | 6 | $table .= ' AS '.$this->getValueWithoutQuotes($item['alias'], 'name'); |
|
| 23 | } |
||
| 24 | 15 | if ('ON' === strtoupper($item['ref_type'])) { |
|
| 25 | $args = [ |
||
| 26 | 15 | $table, |
|
| 27 | 15 | $this->getValueWithoutQuotes($item['ref_clause'][0], 'base_expr'), |
|
| 28 | 15 | $item['ref_clause'][1]['base_expr'], |
|
| 29 | 15 | $this->getValueWithoutQuotes($item['ref_clause'][2], 'base_expr'), |
|
| 30 | ]; |
||
| 31 | 15 | $result[] = $this->format(strtolower($item['join_type']).'Join', $args); |
|
| 32 | } |
||
| 33 | } |
||
| 34 | } |
||
| 35 | |||
| 36 | 102 | return $result; |
|
| 37 | } |
||
| 38 | } |
||
| 39 |