Code Duplication    Length = 12-12 lines in 2 locations

classes/SQL.php 2 locations

@@ 199-210 (lines=12) @@
196
    return $results;
197
  }
198
199
  public function each($query, $params=[], callable $looper = null){
200
    if(!$this->connection()) return false;
201
202
    // ($query,$looper) shorthand
203
    if ($looper===null && is_callable($params)) {$looper = $params; $params = [];}
204
    if( $res = $this->exec($query,$params) ){
205
      if(is_callable($looper))
206
        while ($row = $res->fetchObject()) $looper($row);
207
      else
208
        return $res->fetchAll(PDO::FETCH_CLASS);
209
    }
210
  }
211
212
  public function single($query, $params=[], callable $handler = null){
213
    if(!$this->connection()) return false;
@@ 212-223 (lines=12) @@
209
    }
210
  }
211
212
  public function single($query, $params=[], callable $handler = null){
213
    if(!$this->connection()) return false;
214
215
    // ($query,$handler) shorthand
216
    if ($handler===null && is_callable($params)) {$handler = $params; $params = [];}
217
    if( $res = $this->exec($query,$params) ){
218
        if (is_callable($handler))
219
          $handler($res->fetchObject());
220
        else
221
          return $res->fetchObject();
222
    }
223
  }
224
225
 public function run($script){
226
    if(!$this->connection()) return false;