Code Duplication    Length = 12-12 lines in 2 locations

classes/SQL.php 2 locations

@@ 185-196 (lines=12) @@
182
    return $res ? $res->fetchColumn($column) : null;
183
  }
184
185
  public function each($query, $params=[], callable $looper = null){
186
    if(!$this->connection()) return false;
187
188
    // ($query,$looper) shorthand
189
    if ($looper===null && is_callable($params)) {$looper = $params; $params = [];}
190
    if( $res = $this->exec($query,$params) ){
191
      if(is_callable($looper))
192
        while ($row = $res->fetchObject()) $looper($row);
193
      else
194
        return $res->fetchAll(PDO::FETCH_CLASS);
195
    }
196
  }
197
198
  public function single($query, $params=[], callable $handler = null){
199
    if(!$this->connection()) return false;
@@ 198-209 (lines=12) @@
195
    }
196
  }
197
198
  public function single($query, $params=[], callable $handler = null){
199
    if(!$this->connection()) return false;
200
201
    // ($query,$handler) shorthand
202
    if ($handler===null && is_callable($params)) {$handler = $params; $params = [];}
203
    if( $res = $this->exec($query,$params) ){
204
        if (is_callable($handler))
205
          $handler($res->fetchObject());
206
        else
207
          return $res->fetchObject();
208
    }
209
  }
210
211
 public function run($script){
212
    if(!$this->connection()) return false;