create-prisma-php-app 1.26.520 → 1.26.521
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/src/Lib/PHPX/Utils.php +39 -0
- package/package.json +1 -1
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
<?php
|
|
2
|
+
|
|
3
|
+
namespace Lib\PHPX;
|
|
4
|
+
|
|
5
|
+
class Utils
|
|
6
|
+
{
|
|
7
|
+
public static function mergeClasses(...$classes)
|
|
8
|
+
{
|
|
9
|
+
$classArray = [];
|
|
10
|
+
|
|
11
|
+
foreach ($classes as $class) {
|
|
12
|
+
if (!empty(trim($class))) {
|
|
13
|
+
$splitClasses = explode(' ', $class);
|
|
14
|
+
foreach ($splitClasses as $individualClass) {
|
|
15
|
+
// Extract the base of the class (e.g., bg-red, flex) and replace the previous occurrence
|
|
16
|
+
// You can customize this based on how Tailwind classes work or specific rules you want
|
|
17
|
+
$classPrefix = self::getClassPrefix($individualClass);
|
|
18
|
+
|
|
19
|
+
// Update the array, prioritizing the last occurrence
|
|
20
|
+
$classArray[$classPrefix] = $individualClass;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
// Return the final string of classes after merging
|
|
26
|
+
return implode(' ', array_values($classArray));
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
private static function getClassPrefix($class)
|
|
30
|
+
{
|
|
31
|
+
// Implement logic to determine the base of the class (e.g., bg-red-500 -> bg, flex -> flex)
|
|
32
|
+
// This is just an example, and you might need to adjust based on your use case
|
|
33
|
+
if (preg_match('/^(\w+-)/', $class, $matches)) {
|
|
34
|
+
return $matches[1];
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
return $class;
|
|
38
|
+
}
|
|
39
|
+
}
|