Code Duplication    Length = 14-17 lines in 3 locations

src/voku/db/Result.php 3 locations

@@ 395-408 (lines=14) @@
392
    $data = [];
393
    $this->reset();
394
395
    if ($class && \is_object($class)) {
396
      $propertyAccessor = PropertyAccess::createPropertyAccessor();
397
      /** @noinspection PhpAssignmentInConditionInspection */
398
      while ($row = \mysqli_fetch_assoc($this->_result)) {
399
        $classTmp = clone $class;
400
        $row = $this->cast($row);
401
        foreach ($row as $key => $value) {
402
          $propertyAccessor->setValue($classTmp, $key, $value);
403
        }
404
        $data[] = $classTmp;
405
      }
406
407
      return $data;
408
    }
409
410
    if ($class && $params) {
411
      /** @noinspection PhpAssignmentInConditionInspection */
@@ 461-474 (lines=14) @@
458
    // init
459
    $this->reset();
460
461
    if ($class && \is_object($class)) {
462
      $propertyAccessor = PropertyAccess::createPropertyAccessor();
463
      /** @noinspection PhpAssignmentInConditionInspection */
464
      while ($row = \mysqli_fetch_assoc($this->_result)) {
465
        $classTmp = clone $class;
466
        $row = $this->cast($row);
467
        foreach ($row as $key => $value) {
468
          $propertyAccessor->setValue($classTmp, $key, $value);
469
        }
470
        yield $classTmp;
471
      }
472
473
      return;
474
    }
475
476
    if ($class && $params) {
477
      /** @noinspection PhpAssignmentInConditionInspection */
@@ 887-903 (lines=17) @@
884
      $this->reset();
885
    }
886
887
    if ($class && \is_object($class)) {
888
      $row = \mysqli_fetch_assoc($this->_result);
889
      $row = $row ? $this->cast($row) : false;
890
891
      if (!$row) {
892
        return;
893
      }
894
895
      $propertyAccessor = PropertyAccess::createPropertyAccessor();
896
      foreach ($row as $key => $value) {
897
        $propertyAccessor->setValue($class, $key, $value);
898
      }
899
900
      yield $class;
901
902
      return;
903
    }
904
905
    if ($class && $params) {
906
      $row = \mysqli_fetch_object($this->_result, $class, $params);