| 1 |  |  | <?php | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3 |  |  | namespace ClickHouseDB; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5 |  |  | use ClickHouseDB\Exception\ClickHouseUnavailableException; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6 |  |  | use ClickHouseDB\Exception\DatabaseException; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7 |  |  | use ClickHouseDB\Exception\QueryException; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8 |  |  | use ClickHouseDB\Query\Query; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9 |  |  | use ClickHouseDB\Transport\CurlerRequest; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10 |  |  | use ClickHouseDB\Transport\CurlerResponse; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 12 |  |  | class Statement implements \Iterator | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 13 |  |  | { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 14 |  |  |     private const CLICKHOUSE_ERROR_REGEX = "%Code:\s(\d+)\.\s*DB::Exception\s*:\s*(.*)(?:,\s*e\.what|\(version).*%ius"; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 15 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 16 |  |  |     /** | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 17 |  |  |      * @var string|mixed | 
            
                                                                                                            
                            
            
                                    
            
            
                | 18 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 19 |  |  |     private $_rawData; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 20 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 21 |  |  |     /** | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 22 |  |  |      * @var int | 
            
                                                                                                            
                            
            
                                    
            
            
                | 23 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 24 |  |  |     private $_http_code = -1; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 25 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 26 |  |  |     /** | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 27 |  |  |      * @var CurlerRequest | 
            
                                                                                                            
                            
            
                                    
            
            
                | 28 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 29 |  |  |     private $_request = null; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 30 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 31 |  |  |     /** | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 32 |  |  |      * @var bool | 
            
                                                                                                            
                            
            
                                    
            
            
                | 33 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 34 |  |  |     private $_init = false; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 35 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 36 |  |  |     /** | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 37 |  |  |      * @var Query | 
            
                                                                                                            
                            
            
                                    
            
            
                | 38 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 39 |  |  |     private $query; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 40 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 41 |  |  |     /** | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 42 |  |  |      * @var mixed | 
            
                                                                                                            
                            
            
                                    
            
            
                | 43 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 44 |  |  |     private $format; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 45 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 46 |  |  |     /** | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 47 |  |  |      * @var string | 
            
                                                                                                            
                            
            
                                    
            
            
                | 48 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 49 |  |  |     private $sql = ''; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 50 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 51 |  |  |     /** | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 52 |  |  |      * @var array | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 53 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 54 |  |  |     private $meta; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 55 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 56 |  |  |     /** | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 57 |  |  |      * @var array | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 58 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 59 |  |  |     private $totals; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 60 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 61 |  |  |     /** | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 62 |  |  |      * @var array | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 63 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 64 |  |  |     private $extremes; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 65 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 66 |  |  |     /** | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 67 |  |  |      * @var int | 
            
                                                                                                            
                            
            
                                    
            
            
                | 68 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 69 |  |  |     private $rows; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 70 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 71 |  |  |     /** | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 72 |  |  |      * @var bool|integer | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 73 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 74 |  |  |     private $rows_before_limit_at_least = false; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 75 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 76 |  |  |     /** | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 77 |  |  |      * @var array | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 78 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 79 |  |  |     private $array_data = []; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 80 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 81 |  |  |     /** | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 82 |  |  |      * @var array|null | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 83 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 84 |  |  |     private $statistics = null; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 85 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 86 |  |  |     /** | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 87 |  |  |      * @var int | 
            
                                                                                                            
                            
            
                                    
            
            
                | 88 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 89 |  |  |     public $iterator = 0; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 90 | 45 |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 91 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 92 | 45 |  |     public function __construct(CurlerRequest $request) | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 93 | 45 |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 94 | 45 |  |         $this->_request = $request; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 95 | 45 |  |         $this->format = $this->_request->getRequestExtendedInfo('format'); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 96 | 45 |  |         $this->query = $this->_request->getRequestExtendedInfo('query'); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 97 |  |  |         $this->sql = $this->_request->getRequestExtendedInfo('sql'); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 98 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 99 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 100 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 101 |  |  |      * @return CurlerRequest | 
            
                                                                                                            
                            
            
                                    
            
            
                | 102 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 103 |  |  |     public function getRequest() | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 104 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 105 |  |  |         return $this->_request; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 106 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 107 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 108 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 109 |  |  |      * @return CurlerResponse | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 110 | 39 |  |      * @throws Exception\TransportException | 
            
                                                                                                            
                            
            
                                    
            
            
                | 111 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 112 | 39 |  |     private function response() | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 113 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 114 |  |  |         return $this->_request->response(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 115 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 116 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 117 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 118 |  |  |      * @return mixed | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 119 | 1 |  |      * @throws Exception\TransportException | 
            
                                                                                                            
                            
            
                                    
            
            
                | 120 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 121 | 1 |  |     public function responseInfo() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 122 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 123 |  |  |         return $this->response()->info(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 124 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 125 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 126 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 127 | 10 |  |      * @return mixed|string | 
            
                                                                                                            
                            
            
                                    
            
            
                | 128 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 129 | 10 |  |     public function sql() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 130 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 131 |  |  |         return $this->sql; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 132 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 133 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 134 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 135 |  |  |      * @param string $body | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 136 | 5 |  |      * @return array|bool | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 137 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 138 | 5 |  |     private function parseErrorClickHouse(string $body) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 139 | 5 |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 140 |  |  |         $body = trim($body); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 141 |  |  |         $matches = []; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 142 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 143 |  |  |         // Code: 115. DB::Exception: Unknown setting readonly[0], e.what() = DB::Exception | 
            
                                                                                                            
                            
            
                                    
            
            
                | 144 |  |  |         // Code: 192. DB::Exception: Unknown user x, e.what() = DB::Exception | 
            
                                                                                                            
                            
            
                                    
            
            
                | 145 | 5 |  |         // Code: 60. DB::Exception: Table default.ZZZZZ doesn't exist., e.what() = DB::Exception | 
            
                                                                                                            
                            
            
                                    
            
            
                | 146 | 4 |  |         // Code: 516. DB::Exception: test_username: Authentication failed: password is incorrect or there is no user with such name. (AUTHENTICATION_FAILED) (version 22.8.3.13 (official build)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 147 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 148 |  |  |         if (preg_match(self::CLICKHOUSE_ERROR_REGEX, $body, $matches)) { | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 149 | 1 |  |             return ['code' => $matches[1], 'message' => $matches[2]]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 150 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 151 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 152 |  |  |         return false; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 153 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 154 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 155 |  |  |     private function hasErrorClickhouse(string $body): bool { | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 156 | 8 |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 157 |  |  |         return preg_match(self::CLICKHOUSE_ERROR_REGEX, $body) === 1; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 158 | 8 |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 159 | 2 |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 160 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 161 |  |  |      * @return bool | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 162 | 6 |  |      * @throws Exception\TransportException | 
            
                                                                                                            
                            
            
                                    
            
            
                | 163 | 6 |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 164 | 6 |  |     public function error() | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 165 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 166 | 6 |  |         if (!$this->isError()) { | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 167 | 6 |  |             return false; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 168 | 5 |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 169 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 170 | 5 |  |         $body = $this->response()->body(); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 171 | 4 |  |         $error_no = $this->response()->error_no(); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 172 |  |  |         $error = $this->response()->error(); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 173 | 1 |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 174 | 1 |  |         $dumpStatement = false; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 175 | 1 |  |         if (!$error_no && !$error) { | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 176 |  |  |             $parse = $this->parseErrorClickHouse($body); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 177 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 178 | 1 |  |             if ($parse) { | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 179 | 1 |  |                 throw new DatabaseException($parse['message'] . "\nIN:" . $this->sql(), $parse['code']); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 180 |  |  |             } else { | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 181 |  |  |                 $code = $this->response()->http_code(); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 182 | 2 |  |                 $message = "HttpCode:" . $this->response()->http_code() . " ; " . $this->response()->error() . " ;" . $body; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                            
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 183 | 2 |  |                 $dumpStatement = true; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 184 |  |  |             } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 185 |  |  |         } else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 186 |  |  |             $code = $error_no; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 187 | 2 |  |             $message = $this->response()->error(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 188 | 1 |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 189 | 1 |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 190 |  |  |         $exception = new QueryException($message, $code); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 191 |  |  |         if ($code === CURLE_COULDNT_CONNECT) { | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 192 | 2 |  |             $exception = new ClickHouseUnavailableException($message, $code); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 193 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 194 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 195 |  |  |         if ($dumpStatement) { | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 196 |  |  |             $exception->setRequestDetails($this->_request->getDetails()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 197 |  |  |             $exception->setResponseDetails($this->response()->getDetails()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 198 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 199 | 39 |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 200 |  |  |         throw $exception; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 201 | 39 |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 202 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 203 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 204 | 32 |  |      * @return bool | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 205 |  |  |      * @throws Exception\TransportException | 
            
                                                                                                            
                            
            
                                    
            
            
                | 206 | 32 |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 207 |  |  |     public function isError(): bool | 
            
                                                                                                            
                            
            
                                    
            
            
                | 208 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 209 |  |  |         if ($this->response()->http_code() !== 200) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 210 | 32 |  |             return true; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 211 | 1 |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 212 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 213 |  |  |         if ($this->response()->error_no()) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 214 | 31 |  |             return true; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 215 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 216 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 217 |  |  |         if ($this->hasErrorClickhouse($this->response()->body())) { | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 218 |  |  |             return true; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 219 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 220 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 221 | 30 |  |         return false; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 222 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 223 | 30 |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 224 |  |  |     private function check(): bool | 
            
                                                                                                            
                            
            
                                    
            
            
                | 225 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 226 |  |  |         if (!$this->_request->isResponseExists()) { | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 227 |  |  |             throw QueryException::noResponse(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 228 | 30 |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 229 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 230 |  |  |         if ($this->isError()) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 231 | 29 |  |             $this->error(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 232 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 233 | 29 |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 234 |  |  |         return true; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 235 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 236 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 237 | 29 |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 238 | 29 |  |      * @return bool | 
            
                                                                                                            
                            
            
                                    
            
            
                | 239 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 240 | 29 |  |     public function isInited() | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 241 | 29 |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 242 |  |  |         return $this->_init; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 243 | 29 |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 244 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 245 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 246 | 29 |  |      * @return bool | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 247 |  |  |      * @throws Exception\TransportException | 
            
                                                                                                            
                            
            
                                    
            
            
                | 248 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 249 |  |  |     private function init() | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 250 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 251 |  |  |         if ($this->_init) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 252 | 29 |  |             return false; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 253 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 254 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 255 |  |  |         $this->check(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 256 | 29 |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 257 | 29 |  |         $this->_rawData = $this->response()->rawDataOrJson($this->format); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 258 | 29 |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 259 | 29 |  |         if (!$this->_rawData) { | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 260 |  |  |             $this->_init = true; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 261 |  |  |             return false; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 262 | 29 |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 263 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 264 | 1 |  |         $data = []; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 265 |  |  |         foreach (['meta', 'data', 'totals', 'extremes', 'rows', 'rows_before_limit_at_least', 'statistics'] as $key) { | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 266 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 267 | 28 |  |             if (isset($this->_rawData[$key])) { | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 268 | 28 |  |                 if ($key=='data') { | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 269 |  |  |                     $data=$this->_rawData[$key]; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 270 |  |  |                 } else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 271 |  |  |                     $this->{$key} = $this->_rawData[$key]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 272 | 29 |  |                 } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 273 |  |  |             } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 274 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 275 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 276 | 29 |  |         if (empty($this->meta)) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 277 |  |  |             throw new QueryException('Can`t find meta'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 278 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 279 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 280 |  |  |         $isJSONCompact=(stripos($this->format,'JSONCompact')!==false?true:false); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                            
                                                                                            
                                                                                            
                                                                                            
                                                                                            
                                                                                            
                                                                                            
                                                                                            
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 281 |  |  |         $this->array_data = []; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 282 |  |  |         foreach ($data as $rows) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 283 |  |  |             $r = []; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 284 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 285 |  |  |             if ($isJSONCompact) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 286 |  |  |                 $r[] = $rows; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 287 |  |  |             } else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 288 |  |  |                 foreach ($this->meta as $meta) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 289 |  |  |                     $r[$meta['name']] = $meta['type'] === 'Int64' | 
            
                                                                                                            
                            
            
                                    
            
            
                | 290 |  |  |                         ? (int) $rows[$meta['name']] | 
            
                                                                                                            
                            
            
                                    
            
            
                | 291 |  |  |                         : $rows[$meta['name']]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 292 |  |  |                 } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 293 | 1 |  |             } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 294 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 295 | 1 |  |             $this->array_data[] = $r; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 296 | 1 |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 297 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 298 |  |  |         $this->_init = true; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 299 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 300 |  |  |         return true; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 301 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 302 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 303 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 304 | 1 |  |      * @return array | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 305 |  |  |      * @throws \Exception | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 306 | 1 |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 307 |  |  |     public function extremes() | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 308 | 1 |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 309 |  |  |         $this->init(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 310 |  |  |         return $this->extremes; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 311 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 312 | 1 |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 313 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 314 |  |  |      * @return mixed | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 315 |  |  |      * @throws Exception\TransportException | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 316 |  |  |      */ | 
            
                                                                        
                            
            
                                    
            
            
                | 317 |  |  |     public function totalTimeRequest() | 
            
                                                                        
                            
            
                                    
            
            
                | 318 |  |  |     { | 
            
                                                                        
                            
            
                                    
            
            
                | 319 |  |  |         $this->check(); | 
            
                                                                        
                            
            
                                    
            
            
                | 320 |  |  |         return $this->response()->total_time(); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 321 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 322 |  |  |     } | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 323 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 324 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 325 |  |  |      * @return array | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 326 |  |  |      * @throws \Exception | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 327 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 328 |  |  |     public function extremesMin() | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 329 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 330 |  |  |         $this->init(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 331 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 332 |  |  |         if (empty($this->extremes['min'])) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 333 |  |  |             return []; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 334 | 1 |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 335 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 336 | 1 |  |         return $this->extremes['min']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 337 | 1 |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 338 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 339 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 340 |  |  |      * @return array | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 341 |  |  |      * @throws \Exception | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 342 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 343 |  |  |     public function extremesMax() | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 344 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 345 |  |  |         $this->init(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 346 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 347 |  |  |         if (empty($this->extremes['max'])) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 348 |  |  |             return []; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 349 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 350 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 351 |  |  |         return $this->extremes['max']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 352 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 353 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 354 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 355 |  |  |      * @return array | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 356 |  |  |      * @throws Exception\TransportException | 
            
                                                                                                            
                            
            
                                    
            
            
                | 357 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 358 |  |  |     public function totals() | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 359 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 360 |  |  |         $this->init(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 361 | 2 |  |         return $this->totals; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 362 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 363 | 2 |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 364 | 2 |  |     /** | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 365 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 366 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 367 |  |  |     public function dump() | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 368 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 369 |  |  |         $this->_request->dump(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 370 |  |  |         $this->response()->dump(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 371 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 372 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 373 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 374 |  |  |      * @return bool|int | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 375 |  |  |      * @throws Exception\TransportException | 
            
                                                                                                            
                            
            
                                    
            
            
                | 376 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 377 |  |  |     public function countAll() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 378 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 379 |  |  |         $this->init(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 380 |  |  |         return $this->rows_before_limit_at_least; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 381 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 382 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 383 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 384 |  |  |      * @param bool $key | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 385 |  |  |      * @return array|mixed|null | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 386 |  |  |      * @throws Exception\TransportException | 
            
                                                                                                            
                            
            
                                    
            
            
                | 387 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 388 |  |  |     public function statistics($key = false) | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 389 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 390 |  |  |         $this->init(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 391 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 392 |  |  |         if (!is_array($this->statistics)) { | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 393 |  |  |             return null; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 394 | 8 |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 395 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 396 | 8 |  |         if (!$key) return $this->statistics; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 397 | 8 |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 398 |  |  |         if (!isset($this->statistics[$key])) { | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 399 |  |  |             return null; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 400 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 401 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 402 |  |  |         return $this->statistics[$key]; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 403 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 404 | 3 |  |     } | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 405 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 406 | 3 |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 407 |  |  |      * @return int | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 408 |  |  |      * @throws Exception\TransportException | 
            
                                                                                                            
                            
            
                                    
            
            
                | 409 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 410 | 3 |  |     public function count() | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 411 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 412 | 3 |  |         $this->init(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 413 |  |  |         return $this->rows; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 414 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 415 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 416 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 417 |  |  |      * @return mixed|string | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 418 | 2 |  |      * @throws Exception\TransportException | 
            
                                                                                                            
                            
            
                                    
            
            
                | 419 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 420 | 2 |  |     public function rawData() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 421 | 2 |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 422 |  |  |         if ($this->_init) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 423 | 2 |  |             return $this->_rawData; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 424 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 425 | 2 |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 426 |  |  |         $this->check(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 427 | 2 |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 428 |  |  |         return $this->response()->rawDataOrJson($this->format); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 429 | 2 |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 430 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 431 |  |  |     /** | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 432 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 433 | 2 |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 434 |  |  |     public function resetIterator() | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 435 | 2 |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 436 |  |  |         $this->iterator=0; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 437 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 438 | 2 |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 439 | 1 |  |     public function fetchRow($key = null) | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 440 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 441 |  |  |         $this->init(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 442 | 2 |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 443 |  |  |         $position=$this->iterator; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 444 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 445 |  |  |         if (!isset($this->array_data[$position])) { | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 446 |  |  |             return null; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 447 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 448 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 449 |  |  |         $this->iterator++; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 450 | 18 |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 451 |  |  |         if (!$key) { | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 452 | 18 |  |             return $this->array_data[$position]; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 453 | 18 |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 454 |  |  |         if (!isset($this->array_data[$position][$key])) { | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 455 |  |  |             return null; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 456 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 457 | 18 |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 458 | 3 |  |         return $this->array_data[$position][$key]; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 459 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 460 |  |  |     } | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 461 | 18 |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 462 | 2 |  |      * @param string $key | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 463 |  |  |      * @return mixed|null | 
            
                                                                                                            
                            
            
                                    
            
            
                | 464 |  |  |      * @throws Exception\TransportException | 
            
                                                                                                            
                            
            
                                    
            
            
                | 465 | 17 |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 466 |  |  |     public function fetchOne($key = null) | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 467 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 468 |  |  |         $this->init(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 469 |  |  |         if (!isset($this->array_data[0])) { | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 470 |  |  |             return null; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 471 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 472 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 473 | 4 |  |         if (!$key) { | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 474 |  |  |             return $this->array_data[0]; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 475 | 4 |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 476 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 477 | 4 |  |         if (!isset($this->array_data[0][$key])) { | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 478 | 4 |  |             return null; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 479 | 4 |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 480 | 4 |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 481 |  |  |         return $this->array_data[0][$key]; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 482 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 483 | 4 |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 484 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 485 |  |  |      * @param string|null $path | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 486 |  |  |      * @return array | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 487 |  |  |      * @throws Exception\TransportException | 
            
                                                                                                            
                            
            
                                    
            
            
                | 488 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 489 |  |  |     public function rowsAsTree($path) | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 490 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 491 |  |  |         $this->init(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 492 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 493 |  |  |         $out = []; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 494 |  |  |         foreach ($this->array_data as $row) { | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 495 |  |  |             $d = $this->array_to_tree($row, $path); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 496 |  |  |             $out = array_replace_recursive($d, $out); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 497 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 498 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 499 |  |  |         return $out; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 500 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 501 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 502 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 503 |  |  |      * Return size_upload,upload_content,speed_upload,time_request | 
            
                                                                                                            
                            
            
                                    
            
            
                | 504 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 505 |  |  |      * @return array | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 506 |  |  |      * @throws Exception\TransportException | 
            
                                                                                                            
                            
            
                                    
            
            
                | 507 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 508 |  |  |     public function info_upload() | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 509 | 1 |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 510 |  |  |         $this->check(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 511 | 1 |  |         return [ | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 512 |  |  |             'size_upload'    => $this->response()->size_upload(), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 513 | 1 |  |             'upload_content' => $this->response()->upload_content_length(), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 514 | 1 |  |             'speed_upload'   => $this->response()->speed_upload(), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 515 | 1 |  |             'time_request'   => $this->response()->total_time() | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 516 | 1 |  |         ]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 517 | 1 |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 518 | 1 |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 519 | 1 |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 520 |  |  |      * Return size_upload,upload_content,speed_upload,time_request,starttransfer_time,size_download,speed_download | 
            
                                                                                                            
                            
            
                                    
            
            
                | 521 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 522 |  |  |      * @return array | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 523 |  |  |      * @throws Exception\TransportException | 
            
                                                                                                            
                            
            
                                    
            
            
                | 524 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 525 |  |  |     public function info() | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 526 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 527 | 1 |  |         $this->check(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 528 |  |  |         return [ | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 529 | 1 |  |             'starttransfer_time'    => $this->response()->starttransfer_time(), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 530 |  |  |             'size_download'    => $this->response()->size_download(), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 531 |  |  |             'speed_download'    => $this->response()->speed_download(), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 532 |  |  |             'size_upload'    => $this->response()->size_upload(), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 533 |  |  |             'upload_content' => $this->response()->upload_content_length(), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 534 |  |  |             'speed_upload'   => $this->response()->speed_upload(), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 535 |  |  |             'time_request'   => $this->response()->total_time() | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 536 | 9 |  |         ]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 537 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 538 | 9 |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 539 | 8 |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 540 |  |  |      * get format in sql | 
            
                                                                                                            
                            
            
                                    
            
            
                | 541 |  |  |      * @return mixed | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 542 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 543 |  |  |     public function getFormat() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 544 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 545 |  |  |         return $this->format; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 546 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 547 | 4 |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 548 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 549 | 4 |  |      * @return array | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 550 |  |  |      * @throws Exception\TransportException | 
            
                                                                                                            
                            
            
                                    
            
            
                | 551 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 552 | 4 |  |     public function rows() | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 553 | 4 |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 554 |  |  |         $this->init(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 555 | 4 |  |         return $this->array_data; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 556 | 4 |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 557 | 4 |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 558 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 559 |  |  |      * @return false|string | 
            
                                                                                                            
                            
            
                                    
            
            
                | 560 |  |  |     */ | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 561 |  |  |     public function jsonRows() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 562 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 563 |  |  |         return json_encode($this->rows(), JSON_PRETTY_PRINT); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 564 | 4 |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 565 | 4 |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 566 | 4 |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 567 |  |  |      * @param array|string $arr | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 568 | 4 |  |      * @param null|string|array $path | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 569 | 4 |  |      * @return array | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 570 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 571 |  |  |     private function array_to_tree($arr, $path = null) | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 572 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 573 |  |  |         if (is_array($path)) { | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 574 | 4 |  |             $keys = $path; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 575 |  |  |         } else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 576 | 4 |  |             $args = func_get_args(); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 577 |  |  |             array_shift($args); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 578 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 579 | 4 |  |             if (sizeof($args) < 2) { | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 580 |  |  |                 $separator = '.'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 581 |  |  |                 $keys = explode($separator, $path); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 582 |  |  |             } else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 583 |  |  |                 $keys = $args; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 584 |  |  |             } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 585 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 586 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 587 |  |  |         // | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 588 |  |  |         $tree = $arr; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 589 |  |  |         while (count($keys)) { | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 590 |  |  |             $key = array_pop($keys); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 591 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 592 |  |  |             if (isset($arr[$key])) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 593 |  |  |                 $val = $arr[$key]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 594 |  |  |             } else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 595 |  |  |                 $val = $key; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 596 |  |  |             } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 597 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 598 |  |  |             $tree = array($val => $tree); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 599 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 600 |  |  |         if (!is_array($tree)) { | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 601 |  |  |             return []; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 602 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 603 |  |  |         return $tree; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 604 |  |  |     } | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 605 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 606 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 607 |  |  |     public function rewind(): void { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 608 |  |  |         $this->iterator = 0; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 609 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 610 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 611 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 612 |  |  |      * @return mixed | 
            
                                                                                                            
                            
            
                                    
            
            
                | 613 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 614 |  |  |     #[\ReturnTypeWillChange] | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 615 |  |  |     public function current() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 616 |  |  |         if (!isset($this->array_data[$this->iterator])) { | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 617 |  |  |             return null; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 618 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 619 |  |  |         return $this->array_data[$this->iterator]; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 620 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 621 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 622 |  |  |     public function key(): int { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 623 |  |  |         return $this->iterator; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 624 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 625 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 626 |  |  |     public function next(): void { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 627 |  |  |         ++$this->iterator; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 628 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 629 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 630 |  |  |     public function valid(): bool { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 631 |  |  |         $this->init(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 632 |  |  |         return isset($this->array_data[$this->iterator]); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 633 |  |  |     } | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 634 |  |  | } | 
            
                                                        
            
                                    
            
            
                | 635 |  |  |  |