| 1 |  |  | <?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3 |  |  | /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4 |  |  |  * This file is part of Cycle Database package. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6 |  |  |  * For the full copyright and license information, please view the LICENSE | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7 |  |  |  * file that was distributed with this source code. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8 |  |  |  */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10 |  |  | declare(strict_types=1); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 12 |  |  | namespace Cycle\Database\Config; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 13 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 14 |  |  | use Cycle\Database\Driver\DriverInterface; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 15 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 16 |  |  | /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 17 |  |  |  * Connection configuration described in DBAL config file. Any driver can be | 
            
                                                                                                            
                            
            
                                    
            
            
                | 18 |  |  |  * used as data source for multiple databases as table prefix and quotation | 
            
                                                                                                            
                            
            
                                    
            
            
                | 19 |  |  |  * defined on Database instance level. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 20 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 21 |  |  |  * @template T of PDOConnectionConfig | 
            
                                                                                                            
                            
            
                                    
            
            
                | 22 |  |  |  */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 23 |  |  | abstract class DriverConfig | 
            
                                                                                                            
                            
            
                                    
            
            
                | 24 |  |  | { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 25 |  |  |     use StateTrait; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 26 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 27 |  |  |     protected array $defaultOptions = [ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 28 |  |  |         'withDatetimeMicroseconds' => false, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 29 |  |  |     ]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 30 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 31 |  |  |     public array $options = []; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 32 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 33 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 34 |  |  |      * @param T $connection | 
            
                                                                                                            
                            
            
                                    
            
            
                | 35 | 60 |  |      * @param class-string<DriverInterface> $driver | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 36 |  |  |      * @param bool $reconnect Allow reconnects | 
            
                                                                                                            
                            
            
                                    
            
            
                | 37 |  |  |      * @param non-empty-string $timezone All datetime objects will be converted | 
            
                                                                                                            
                            
            
                                    
            
            
                | 38 |  |  |      *        relative to this timezone (must match with DB timezone!) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 39 |  |  |      * @param bool $queryCache Enables query caching | 
            
                                                                                                            
                            
            
                                    
            
            
                | 40 |  |  |      * @param bool $readonlySchema Disable schema modifications | 
            
                                                                                                            
                            
            
                                    
            
            
                | 41 |  |  |      * @param bool $readonly Disable write expressions | 
            
                                                                                                            
                            
            
                                    
            
            
                | 42 |  |  |      * @param array{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 43 |  |  |      *     withDatetimeMicroseconds?: bool | 
            
                                                                                                            
                            
            
                                    
            
            
                | 44 | 60 |  |      * } $options | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 45 |  |  |      */ | 
            
                                                                        
                            
            
                                    
            
            
                | 46 |  |  |     public function __construct( | 
            
                                                                        
                            
            
                                    
            
            
                | 47 |  |  |         public ConnectionConfig $connection, | 
            
                                                                        
                            
            
                                    
            
            
                | 48 |  |  |         public string $driver, | 
            
                                                                        
                            
            
                                    
            
            
                | 49 |  |  |         public bool $reconnect = true, | 
            
                                                                        
                            
            
                                    
            
            
                | 50 |  |  |         public string $timezone = 'UTC', | 
            
                                                                        
                            
            
                                    
            
            
                | 51 |  |  |         public bool $queryCache = true, | 
            
                                                                        
                            
            
                                    
            
            
                | 52 |  |  |         public bool $readonlySchema = false, | 
            
                                                                        
                            
            
                                    
            
            
                | 53 |  |  |         public bool $readonly = false, | 
            
                                                                        
                            
            
                                    
            
            
                | 54 |  |  |         array $options = [] | 
            
                                                                        
                            
            
                                    
            
            
                | 55 |  |  |     ) { | 
            
                                                                        
                            
            
                                    
            
            
                | 56 |  |  |         $this->options = $options + $this->defaultOptions; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 57 |  |  |     } | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 58 |  |  | } | 
            
                                                        
            
                                    
            
            
                | 59 |  |  |  |