Code Duplication    Length = 17-20 lines in 2 locations

src/voku/db/DB.php 2 locations

@@ 606-622 (lines=17) @@
603
   *
604
   * @return bool <p>This will return true or false indicating success of transaction</p>
605
   */
606
  public function beginTransaction(): bool
607
  {
608
    if ($this->_in_transaction === true) {
609
      $this->_debug->displayError('Error: mysql server already in transaction!', false);
610
611
      return false;
612
    }
613
614
    $this->clearErrors(); // needed for "$this->endTransaction()"
615
    $this->_in_transaction = true;
616
    $return = \mysqli_autocommit($this->link, false);
617
    if ($return === false) {
618
      $this->_in_transaction = false;
619
    }
620
621
    return $return;
622
  }
623
624
  /**
625
   * Clear the errors in "_debug->_errors".
@@ 837-856 (lines=20) @@
834
   *
835
   * @return bool <p>This will return true or false indicating success of transactions.</p>
836
   */
837
  public function endTransaction(): bool
838
  {
839
    if ($this->_in_transaction === false) {
840
      $this->_debug->displayError('Error: mysql server is not in transaction!', false);
841
842
      return false;
843
    }
844
845
    if (!$this->errors()) {
846
      $return = \mysqli_commit($this->link);
847
    } else {
848
      $this->rollback();
849
      $return = false;
850
    }
851
852
    \mysqli_autocommit($this->link, true);
853
    $this->_in_transaction = false;
854
855
    return $return;
856
  }
857
858
  /**
859
   * Get all errors from "$this->_errors".