Skip to content

Commit

Permalink
Merge pull request #30 from Planetbiru/feature/2.5
Browse files Browse the repository at this point in the history
Feature/2.5
  • Loading branch information
kamshory authored Nov 5, 2024
2 parents 1091b78 + e07f9b1 commit ef00e68
Show file tree
Hide file tree
Showing 39 changed files with 407 additions and 333 deletions.
56 changes: 31 additions & 25 deletions src/Database/PicoDataComparation.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ class PicoDataComparation
* Creates a comparison for equality.
*
* @param mixed $value The value to compare.
* @return self The PicoDataComparation object.
* @return self Returns the current instance for method chaining.
*/
public static function equals($value)
{
Expand All @@ -73,7 +73,7 @@ public static function equals($value)
* Creates a comparison for inequality.
*
* @param mixed $value The value to compare.
* @return self The PicoDataComparation object.
* @return self Returns the current instance for method chaining.
*/
public static function notEquals($value)
{
Expand All @@ -84,7 +84,7 @@ public static function notEquals($value)
* Creates a comparison for inclusion in a set.
*
* @param mixed[] $values The values to compare against.
* @return self The PicoDataComparation object.
* @return self Returns the current instance for method chaining.
*/
public static function in($values)
{
Expand All @@ -95,7 +95,7 @@ public static function in($values)
* Creates a comparison for exclusion from a set.
*
* @param mixed[] $values The values to compare against.
* @return self The PicoDataComparation object.
* @return self Returns the current instance for method chaining.
*/
public static function notIn($values)
{
Expand All @@ -106,7 +106,7 @@ public static function notIn($values)
* Creates a comparison using the LIKE operator.
*
* @param mixed $value The value to compare.
* @return self The PicoDataComparation object.
* @return self Returns the current instance for method chaining.
*/
public static function like($value)
{
Expand All @@ -117,7 +117,7 @@ public static function like($value)
* Creates a comparison using the NOT LIKE operator.
*
* @param mixed $value The value to compare.
* @return self The PicoDataComparation object.
* @return self Returns the current instance for method chaining.
*/
public static function notLike($value)
{
Expand All @@ -128,7 +128,7 @@ public static function notLike($value)
* Creates a comparison for less than.
*
* @param mixed $value The value to compare.
* @return self The PicoDataComparation object.
* @return self Returns the current instance for method chaining.
*/
public static function lessThan($value)
{
Expand All @@ -139,7 +139,7 @@ public static function lessThan($value)
* Creates a comparison for greater than.
*
* @param mixed $value The value to compare.
* @return self The PicoDataComparation object.
* @return self Returns the current instance for method chaining.
*/
public static function greaterThan($value)
{
Expand All @@ -150,7 +150,7 @@ public static function greaterThan($value)
* Creates a comparison for less than or equal to.
*
* @param mixed $value The value to compare.
* @return self The PicoDataComparation object.
* @return self Returns the current instance for method chaining.
*/
public static function lessThanOrEquals($value)
{
Expand All @@ -161,7 +161,7 @@ public static function lessThanOrEquals($value)
* Creates a comparison for greater than or equal to.
*
* @param mixed $value The value to compare.
* @return self The PicoDataComparation object.
* @return self Returns the current instance for method chaining.
*/
public static function greaterThanOrEquals($value)
{
Expand All @@ -188,69 +188,75 @@ public function __construct($value, $comparison = self::EQUALS)
}

/**
* Gets the appropriate equals operator based on value.
* Returns the appropriate equals operator based on the value's state.
*
* @return string
* If the value is null or of type null, returns the IS operator;
* otherwise, returns the standard equals operator.
*
* @return string The equals operator.
*/
private function _equals()
{
return ($this->value === null || $this->type == self::TYPE_NULL) ? self::IS : self::EQUALS;
}

/**
* Gets the appropriate not equals operator based on value.
* Returns the appropriate not equals operator based on the value's state.
*
* If the value is null or of type null, returns the IS NOT operator;
* otherwise, returns the standard not equals operator.
*
* @return string
* @return string The not equals operator.
*/
private function _notEquals()
{
return ($this->value === null || $this->type == self::TYPE_NULL) ? self::IS_NOT : self::NOT_EQUALS;
}

/**
* Gets the less than operator.
* Returns the less than operator.
*
* @return string
* @return string The less than operator.
*/
private function _lessThan()
{
return self::LESS_THAN;
}

/**
* Gets the greater than operator.
* Returns the greater than operator.
*
* @return string
* @return string The greater than operator.
*/
private function _greaterThan()
{
return self::GREATER_THAN;
}

/**
* Gets the less than or equals operator.
* Returns the less than or equals operator.
*
* @return string
* @return string The less than or equals operator.
*/
private function _lessThanOrEquals()
{
return self::LESS_THAN_OR_EQUALS;
}

/**
* Gets the greater than or equals operator.
* Returns the greater than or equals operator.
*
* @return string
* @return string The greater than or equals operator.
*/
private function _greaterThanOrEquals()
{
return self::GREATER_THAN_OR_EQUALS;
}

/**
* Gets the comparison operator based on the value and type.
* Determines the comparison operator based on the current value and its type.
*
* @return string
* @return string The comparison operator corresponding to the current state.
*/
public function getComparison() // NOSONAR
{
Expand Down Expand Up @@ -278,7 +284,7 @@ public function getComparison() // NOSONAR
/**
* Gets the value being compared.
*
* @return mixed
* @return mixed The value that is currently being compared.
*/
public function getValue()
{
Expand Down
44 changes: 33 additions & 11 deletions src/Database/PicoDatabase.php
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ private function constructConnectionString($withDatabase = true)
/**
* Disconnect from the database.
*
* @return self Returns the instance of the current object for method chaining.
* @return self Returns the current instance for method chaining.
*/
public function disconnect()
{
Expand All @@ -289,7 +289,7 @@ public function disconnect()
* Set the time zone offset.
*
* @param string $timeZoneOffset Client time zone.
* @return self Returns the instance of the current object for method chaining.
* @return self Returns the current instance for method chaining.
*/
public function setTimeZoneOffset($timeZoneOffset)
{
Expand All @@ -302,7 +302,7 @@ public function setTimeZoneOffset($timeZoneOffset)
* Change the database.
*
* @param string $databaseName Database name.
* @return self Returns the instance of the current object for method chaining.
* @return self Returns the current instance for method chaining.
*/
public function useDatabase($databaseName)
{
Expand Down Expand Up @@ -695,9 +695,12 @@ public function getDatabaseType()
}

/**
* Magic method to debug the object.
* Convert the object to a JSON string representation for debugging.
*
* @return string Returns a JSON representation of the object's state.
* This method is intended for debugging purposes only and provides
* a JSON representation of the object's state.
*
* @return string The JSON representation of the object.
*/
public function __toString()
{
Expand All @@ -708,12 +711,22 @@ public function __toString()
return json_encode($val);
}


/**
* Set callback function when executing queries that modify data.
* Get callback function when executing queries that modify data.
*
* @param callable|null $callbackExecuteQuery Callback function when executing queries that modify data.
* @return callable|null
*/
public function getCallbackExecuteQuery()
{
return $this->callbackExecuteQuery;
}

/**
* Set callback function when executing queries that modify data.
*
* @return self
* @param callable|null $callbackExecuteQuery Callback function when executing queries that modify data.
* @return self Returns the current instance for method chaining.
*/
public function setCallbackExecuteQuery($callbackExecuteQuery)
{
Expand All @@ -723,11 +736,20 @@ public function setCallbackExecuteQuery($callbackExecuteQuery)
}

/**
* Set callback function when executing any query.
* Get callback function when executing any query.
*
* @param callable|null $callbackDebugQuery Callback function when executing any query.
* @return callable|null
*/
public function getCallbackDebugQuery()
{
return $this->callbackDebugQuery;
}

/**
* Set callback function when executing any query.
*
* @return self
* @param callable|null $callbackDebugQuery Callback function when executing any query.
* @return self Returns the current instance for method chaining.
*/
public function setCallbackDebugQuery($callbackDebugQuery)
{
Expand Down
Loading

0 comments on commit ef00e68

Please sign in to comment.