-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathClasses.php
39 lines (32 loc) · 954 Bytes
/
Classes.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
<?php
namespace Flying\Util\Css;
class Classes extends AbstractClasses
{
public static function from(mixed ...$classes): static
{
return new self(...$classes);
}
private function clone(array $classes): self
{
$instance = new self();
$instance->classes = $classes;
return $instance;
}
public function with(mixed ...$classes): static
{
return $this->clone(array_merge($this->classes, $this->classesList($classes)));
}
public function without(mixed ...$classes): static
{
$classes = $this->classesList($classes);
return $this->filter(static fn(string $class): bool => !array_key_exists($class, $classes));
}
public function filter(callable $filter): static
{
return $this->clone(array_filter($this->classes, $filter, ARRAY_FILTER_USE_KEY));
}
public function clear(): static
{
return $this->clone([]);
}
}