| Conditions | 5 |
| Paths | 6 |
| Total Lines | 25 |
| Code Lines | 12 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 39 | public static function build($component, array $options = []) |
||
| 40 | { |
||
| 41 | if (! $component instanceof WithKeyword) { |
||
|
|
|||
| 42 | throw new RuntimeException('Can not build a component that is not a WithKeyword'); |
||
| 43 | } |
||
| 44 | |||
| 45 | if (! isset($component->statement)) { |
||
| 46 | throw new RuntimeException('No statement inside WITH'); |
||
| 47 | } |
||
| 48 | |||
| 49 | $str = $component->name; |
||
| 50 | |||
| 51 | if ($component->columns) { |
||
| 52 | $str .= ArrayObj::build($component->columns); |
||
| 53 | } |
||
| 54 | |||
| 55 | $str .= ' AS ('; |
||
| 56 | |||
| 57 | foreach ($component->statement->statements as $statement) { |
||
| 58 | $str .= $statement->build(); |
||
| 59 | } |
||
| 60 | |||
| 61 | $str .= ')'; |
||
| 62 | |||
| 63 | return $str; |
||
| 64 | } |
||
| 66 |