| Total Complexity | 8 |
| Total Lines | 57 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 9 | abstract class Statement implements StatementInterface { |
||
| 10 | private AliasReplacer $aliasReplacer; |
||
| 11 | |||
| 12 | /** |
||
| 13 | * @param Database $db |
||
| 14 | * @param array<string, mixed> $options |
||
| 15 | */ |
||
| 16 | public function __construct( |
||
| 17 | private Database $db, |
||
| 18 | private array $options = [] |
||
| 19 | ) { |
||
| 20 | $this->aliasReplacer = new AliasReplacer($db->getAliasRegistry()); |
||
| 21 | } |
||
| 22 | |||
| 23 | /** |
||
| 24 | * @param bool $stop |
||
| 25 | * @return $this |
||
| 26 | */ |
||
| 27 | public function debug($stop = true) { |
||
| 28 | if(array_key_exists('debug_formatter', $this->options)) { |
||
| 29 | $this->options['debug_formatter'](); |
||
| 30 | } elseif(PHP_SAPI === 'cli') { |
||
| 31 | echo "\n{$this->__toString()}\n"; |
||
| 32 | } else { |
||
| 33 | echo "<pre>{$this->__toString()}</pre>"; |
||
| 34 | } |
||
| 35 | if($stop) { |
||
| 36 | exit; |
||
|
|
|||
| 37 | } |
||
| 38 | return $this; |
||
| 39 | } |
||
| 40 | |||
| 41 | /** |
||
| 42 | * @return Statement |
||
| 43 | */ |
||
| 44 | public function cloneStatement(): Statement { |
||
| 46 | } |
||
| 47 | |||
| 48 | /** |
||
| 49 | * @return AliasReplacer |
||
| 50 | */ |
||
| 51 | public function aliasReplacer(): AliasReplacer { |
||
| 52 | return $this->aliasReplacer; |
||
| 53 | } |
||
| 54 | |||
| 55 | /** |
||
| 56 | * @return Database |
||
| 57 | */ |
||
| 58 | protected function db(): Database { |
||
| 60 | } |
||
| 61 | |||
| 62 | /** |
||
| 63 | * @return string |
||
| 64 | */ |
||
| 65 | abstract public function __toString(): string; |
||
| 66 | } |
||
| 67 |
In general, usage of exit should be done with care and only when running in a scripting context like a CLI script.