Skip to content

Commit

Permalink
convert static methods to normal methods
Browse files Browse the repository at this point in the history
  • Loading branch information
BMTmohammedtaha committed Dec 6, 2024
1 parent 25e28cc commit 32746c3
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 59 deletions.
4 changes: 0 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,4 @@

},
"minimum-stability": "stable"
<<<<<<< HEAD
}
=======
}
>>>>>>> 145a7cd92f06365c9f0ca190efdc6e1766c29364
12 changes: 4 additions & 8 deletions src/ArrayToString.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class ArrayToString
* @param array $array The input array.
* @return string The string representation of the array.
*/
public static function array(array $array): string
public function array(array $array): string
{
if (empty($array)) {
return '[]';
Expand All @@ -34,7 +34,7 @@ public static function array(array $array): string
* @param string $separator The separator used to join the array elements.
* @return string The resulting string.
*/
public static function arrayToText(array $data, string $separator = ','): string
public function arrayToText(array $data, string $separator = ','): string
{
return join($separator, $data);
}
Expand All @@ -45,13 +45,9 @@ public static function arrayToText(array $data, string $separator = ','): string
* @param array $data The input array.
* @return string The URL-friendly slug.
*/
<<<<<<< HEAD
public static function arrayToSlug(array $data): string
=======
public function arrayToSlug(array $data): string
>>>>>>> 145a7cd92f06365c9f0ca190efdc6e1766c29364
{
return static::arrayToText($data, '-');
return $this->arrayToText($data, '-');
}

/**
Expand All @@ -60,7 +56,7 @@ public function arrayToSlug(array $data): string
* @param array|string $data The input array or JSON string.
* @return string The key-value pair string representation.
*/
public static function arrayToTextKeyValue($data): string
public function arrayToTextKeyValue($data): string
{
if (is_string($data)) {
$data = json_decode($data, true);
Expand Down
12 changes: 2 additions & 10 deletions src/DateToString.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,7 @@ class DateToString
* @param int $time The time value in seconds.
* @return string The formatted time string (HH:MM:SS).
*/
<<<<<<< HEAD
public static function formatTime(int $time): string
=======
public function formatTime(int $time): string
>>>>>>> 145a7cd92f06365c9f0ca190efdc6e1766c29364
{
$hours = gmdate('H', $time);
$minutes = gmdate('i', $time);
Expand All @@ -31,12 +27,8 @@ public function formatTime(int $time): string
* @param int $timestamp The timestamp value.
* @return string The formatted date string (YYYY-MM-DD).
*/
<<<<<<< HEAD
public static function formatDate(int $timestamp): string
=======
public function formatDate(int $timestamp): string
>>>>>>> 145a7cd92f06365c9f0ca190efdc6e1766c29364
public static function formatDate(int $timestamp, string $format = 'Y-m-d'): string
{
return date('Y-m-d', $timestamp);
return date($format, $timestamp);
}
}
48 changes: 11 additions & 37 deletions src/TextToString.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,7 @@ class TextToString
* @param string $text The input string.
* @return string The string converted to uppercase.
*/
<<<<<<< HEAD
public static function toUppercase(string $text): string
=======
public function toUppercase(string $text): string
>>>>>>> 145a7cd92f06365c9f0ca190efdc6e1766c29364
{
return strtoupper($text);
}
Expand All @@ -27,11 +23,7 @@ public function toUppercase(string $text): string
* @param string $text The input string.
* @return string The string converted to lowercase.
*/
<<<<<<< HEAD
public static function toLowercase(string $text): string
=======
public function toLowercase(string $text): string
>>>>>>> 145a7cd92f06365c9f0ca190efdc6e1766c29364
{
return strtolower($text);
}
Expand All @@ -42,11 +34,7 @@ public function toLowercase(string $text): string
* @param string $text The input string.
* @return string The string with tags stripped.
*/
<<<<<<< HEAD
public static function strip(string $text): string
=======
public function strip(string $text): string
>>>>>>> 145a7cd92f06365c9f0ca190efdc6e1766c29364
{
return strip_tags($text);
}
Expand All @@ -57,11 +45,7 @@ public function strip(string $text): string
* @param mixed $variable The variable to get the name from.
* @return string The name of the variable.
*/
<<<<<<< HEAD
public static function nameVar($variable): string
=======
public function nameVar($variable): string
>>>>>>> 145a7cd92f06365c9f0ca190efdc6e1766c29364
{
$backtrace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 2);
$callerLine = $backtrace[1]['line'];
Expand All @@ -79,27 +63,30 @@ public function nameVar($variable): string
* Converts a string to a URL-friendly slug.
*
* @param string $text The input string.
* @param string $separator separator symbol.
* @return string The URL-friendly slug.
*/
<<<<<<< HEAD
public static function textToSlug($text): string
=======
public function textToSlug($text): string
>>>>>>> 145a7cd92f06365c9f0ca190efdc6e1766c29364
public function textToSlug(string $text, string $separator): string
{
// Convert the text to lowercase
$text = strtolower($text);

// Replace spaces and special characters with dashes
$text = preg_replace('/[^a-z0-9]+/', '-', $text);
$text = preg_replace('/[^a-z0-9]+/', $separator, $text);

// Remove leading and trailing dashes
$text = trim($text, '-');
$text = trim($text, $separator);

return $text;
}

<<<<<<< HEAD
/**
* Converts a string to a camel case
*
* @param string $string
* @return string
*/

public static function snakeToCamel(string $string): string
{
$words = explode('_', $string);
Expand All @@ -123,19 +110,13 @@ public static function camelToSnake(string $inputString): string
return $outputString;
}

=======
>>>>>>> 145a7cd92f06365c9f0ca190efdc6e1766c29364
/**
* Converts a URL-friendly slug back to a readable text.
*
* @param string $slug The input slug.
* @return string The readable text.
*/
<<<<<<< HEAD
public static function slugToText($slug): string
=======
public function slugToText($slug): string
>>>>>>> 145a7cd92f06365c9f0ca190efdc6e1766c29364
{
// Replace dashes with spaces
$text = str_replace('-', ' ', $slug);
Expand All @@ -152,11 +133,7 @@ public function slugToText($slug): string
* @param int $length The length of the random text.
* @return string The generated random text.
*/
<<<<<<< HEAD
public static function generateRandomText($length): string
=======
public function generateRandomText($length): string
>>>>>>> 145a7cd92f06365c9f0ca190efdc6e1766c29364
{
$characters = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';
$randomText = '';
Expand All @@ -168,7 +145,6 @@ public function generateRandomText($length): string

return $randomText;
}
<<<<<<< HEAD

/**
* Converts a hyphen-separated text to camel case.
Expand Down Expand Up @@ -198,6 +174,4 @@ function dashToCamelCase(string $text): string

return $convertedText;
}
=======
>>>>>>> 145a7cd92f06365c9f0ca190efdc6e1766c29364
}

0 comments on commit 32746c3

Please sign in to comment.