public function getTransaction( $transaction = self::TRANSACTION_LAST_USED, $throwExceptionIfNotFound = true )
    {

        if( $transaction === self::TRANSACTIONS_ALL ) {
            return array_keys( $this->queue );
        }

        if( $transaction === self::TRANSACTION_LAST_CREATED ) {
            if( !$this->queue) {
                $this->newTransaction();
            }
            $queue = array_keys( $this->queue );
            return array_pop( $queue );
        }

        if( $transaction === self::TRANSACTION_LAST_USED ) {
            if( !$this->queue) {
                $this->newTransaction();
            }
            return $this->lastTransaction;
        }

        if( $transaction === self::TRANSACTION_NEW ) {
            return $this->newTransaction();
        }

        if( !array_key_exists( $transaction, $this->queue ) ) {
            if( $throwExceptionIfNotFound ) {
                throw new TransactionDoesNotExistException(
                    "Transaction with this name `{$transaction}` doesn't exist. Sorry."
                );
            }
            return null;
        }

        return $transaction;

    }
public function getTransaction( $transaction = self::TRANSACTION_LAST_USED, $throwExceptionIfNotFound = true )
    {

        if( $transaction === self::TRANSACTIONS_ALL ) {
            return array_keys( $this->queue );
        }

        if( $transaction === self::TRANSACTION_LAST_CREATED ) {
            if( !$this->queue) {
                $this->newTransaction();
            }
            $queue = array_keys( $this->queue );
            return array_pop( $queue );
        }

        if( $transaction === self::TRANSACTION_LAST_USED ) {
            if( !$this->queue) {
                $this->newTransaction();
            }
            return $this->lastTransaction;
        }

        if( $transaction === self::TRANSACTION_NEW ) {
            return $this->newTransaction();
        }

        if( !array_key_exists( $transaction, $this->queue ) ) {
            if( $throwExceptionIfNotFound ) {
                throw new TransactionDoesNotExistException(
                    "Transaction with this name `{$transaction}` doesn't exist. Sorry."
                );
            }
            return null;
        }

        return $transaction;

    }
public function getTransaction ( $ transaction = self :: TRANSACTION_LAST_USED , $ throwExceptionIfNotFound = true ) { if ( $ transaction === self :: TRANSACTIONS_ALL ) { return array_keys ( $ this -> queue ) ; } if ( $ transaction === self :: TRANSACTION_LAST_CREATED ) { if ( ! $ this -> queue ) { $ this -> newTransaction ( ) ; } $ queue = array_keys ( $ this -> queue ) ; return array_pop ( $ queue ) ; } if ( $ transaction === self :: TRANSACTION_LAST_USED ) { if ( ! $ this -> queue ) { $ this -> newTransaction ( ) ; } return $ this -> lastTransaction ; } if ( $ transaction === self :: TRANSACTION_NEW ) { return $ this -> newTransaction ( ) ; } if ( ! array_key_exists ( $ transaction , $ this -> queue ) ) { if ( $ throwExceptionIfNotFound ) { throw new TransactionDoesNotExistException ( "Transaction with this name `{$transaction}` doesn't exist. Sorry." ) ; } return null ; } return $ transaction ; }
Get a transaction name

@param scalar The name of a transaction;
@param bool Throw exception if we can't find.

@return scalar|false in the event of not found
Get a transaction name