Skip to content

Commit 00ae21c

Browse files
committed
add some simple functions
1 parent b01baa1 commit 00ae21c

2 files changed

Lines changed: 20 additions & 1 deletion

File tree

src/Helpers.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,4 +173,16 @@ public static function hasDirection(string $str): bool
173173
{
174174
return preg_match('/\b(top|bottom|right|left)\b/i', $str);
175175
}
176+
177+
/**
178+
* check if string include other string
179+
*
180+
* @param string $str
181+
* @param string $needle
182+
* @return bool
183+
*/
184+
public static function strIncludes(string $str, string $needle): bool
185+
{
186+
return strpos($str, $needle) !== false;
187+
}
176188
}

src/Manipulate.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,14 +43,21 @@ public static function complement($value): void
4343
*/
4444
public static function negate($value): void
4545
{
46-
if ($value instanceof ValueList) {
46+
if ($value instanceof CSSFunction && Helpers::strIncludes($value->getName(), 'calc')) {
47+
$arguments = implode($value->getListSeparator(), $value->getArguments());
48+
$arguments = "-1*($arguments)";
49+
$value->setListComponents([$arguments]);
50+
51+
} else if ($value instanceof ValueList) {
4752
foreach ($value->getListComponents() as $part) {
4853
self::negate($part);
4954
}
55+
5056
} else if ($value instanceof Size) {
5157
if ($value->getSize() != 0) {
5258
$value->setSize(-$value->getSize());
5359
}
60+
5461
}
5562
}
5663
}

0 commit comments

Comments
 (0)