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