Code Duplication    Length = 17-20 lines in 2 locations

src/voku/db/DB.php 2 locations

@@ 584-600 (lines=17) @@
581
   *
582
   * @return bool <p>This will return true or false indicating success of transaction</p>
583
   */
584
  public function beginTransaction(): bool
585
  {
586
    if ($this->_in_transaction === true) {
587
      $this->_debug->displayError('Error: mysql server already in transaction!', false);
588
589
      return false;
590
    }
591
592
    $this->clearErrors(); // needed for "$this->endTransaction()"
593
    $this->_in_transaction = true;
594
    $return = \mysqli_autocommit($this->link, false);
595
    if ($return === false) {
596
      $this->_in_transaction = false;
597
    }
598
599
    return $return;
600
  }
601
602
  /**
603
   * Clear the errors in "_debug->_errors".
@@ 780-799 (lines=20) @@
777
   *
778
   * @return bool <p>This will return true or false indicating success of transactions.</p>
779
   */
780
  public function endTransaction(): bool
781
  {
782
    if ($this->_in_transaction === false) {
783
      $this->_debug->displayError('Error: mysql server is not in transaction!', false);
784
785
      return false;
786
    }
787
788
    if (!$this->errors()) {
789
      $return = \mysqli_commit($this->link);
790
    } else {
791
      $this->rollback();
792
      $return = false;
793
    }
794
795
    \mysqli_autocommit($this->link, true);
796
    $this->_in_transaction = false;
797
798
    return $return;
799
  }
800
801
  /**
802
   * Get all errors from "$this->_errors".