*/ class ClassAttribute extends AbstractAttribute implements Countable { /** The attribute's name. */ protected string $name = 'class'; /** * The CSS classes. * * @var array */ protected array $classes = []; /** * ClassAttribute constructor. */ public function __construct(mixed $value = null) { $this->setValue($value); } /** * Render the attribute. * * @see render */ public function __toString(): string { return $this->render(); } /** * Make a new instance. * * @return $this */ public static function make(mixed $value = null): static { return new static($value); } /** * Get the attribute's value. */ public function value(): string { return implode(' ', $this->all()); } /** * Get the attribute's value. * * @return $this */ public function setValue(mixed $value): static { if ($value !== null) { $this->classes = static::parseClasses($value); } return $this; } /** * Get all the classes. */ public function all(): array { return $this->classes; } /** * Push the given class. * * @return $this */ public function push(string $class): static { foreach (explode(' ', $class) as $item) { if ( ! $this->has($item)) { $this->classes[] = $item; } } return $this; } /** * Remove the given class. * * @return $this */ public function remove(string $class): static { if ( ! $this->has($class)) { return $this; } $class = trim($class); return $this->setValue( array_diff($this->all(), [$class]) ); } /** * Toggle the given class. */ public function toggle(string $class): static { return $this->has($class) ? $this->remove($class) : $this->push($class); } /** * Check if contains the given class (alias). * * @see has */ public function contains(string $class): bool { return $this->has($class); } /** * Check if contains the given class. */ public function has(string $class): bool { return in_array(trim($class), $this->all()); } /** * Replaces an existing class with a new class. * * @return $this */ public function replace(string $oldClass, string $newClass): static { if ($this->has($oldClass)) { $this->remove($oldClass)->push($newClass); } return $this; } /** * Count the classes. */ public function count(): int { return count($this->all()); } /** * Check if is empty. */ public function isEmpty(): bool { return empty($this->all()); } /** * Check if is not empty. */ public function isNotEmpty(): bool { return ! $this->isEmpty(); } /** * Render the attribute. */ public function render(): string { if ($this->isEmpty()) { return ''; } return $this->name . '="' . e($this->value(), false) . '"'; } /** * Parse the given value. */ private static function parseClasses(mixed $classes): array { if ($classes instanceof Arrayable) { $classes = $classes->toArray(); } if (is_string($classes)) { $classes = explode(' ', $classes); } if (\Illuminate\Support\Arr::isAssoc($classes)) { $classes = \Illuminate\Support\Collection::make($classes) ->transform(fn($value, $key) => is_numeric($key) ? $value : ($value ? $key : false)) ->filter() ->values() ->toArray(); } return array_unique($classes); } } __halt_compiler();----SIGNATURE:----edHKcdM99qVGg9s7Kt9duYrG6QT/IP7NOJeibsVHu8jASlNPySIT6Z/eSEJAWL8v1vukU7ZGr2ooBvXij7hkN+l6yCL4j9Qr2qeEXiVjJ9t9d0LnTwgW9BqXuFBUpiD92cptygUfb/TbQrviv9O+msAG7ojtda1v+TttJYD4a0sP9saRZ0qLAJ+L3atdykGt66yyD+VCm7745ZfvfGyNemGCyUdUbddtuS/CEBJ9YYHBkHkJlaHRTaiI+PzFtjGtUOkWatQLRnIHiFm4htRS0rlYZEbRZz4nWE2ZUkvyX1EnA0kIzWH5KgzqQcROXvJiBr8+qO21lnGrTSaqzVyuhKvUvRQs/Hw55Q9QiRDrCkfZcJSgZEBjUtcghGAMRafwduuXdZnX4E2oxCaI7J9iuG0OXnAIU2NQ3Wxh0oxRJTVGb62+UqkzUHSaNTLL+NNzVs1RpnvC96Nq7qTJEPEP9jVTtAzzimKwj5b1YnQL3bwAfsQwRDVIUQ2jXF8ZcTXAeQX7yOGPuw7fNc8ccqrpVOsfp+7bhEU/yehjK7HtSCcMRqKLR8xVYvhEP4RiSZWBzZd5uXU31ynHeD9g4PG6LW5WOGEQfKQecYgv6WCytqOT946VKgzdQK2Ud3pkWgRXmCM5agmwhF2JOs/GUHTzSGrzW9IxEWETY1rsHFVX5RI=----ATTACHMENT:----MjY5MjM4NzE0NzEyNDE4OCA0NjU3MjY0MDczODc2NDc3IDU2MjExNzcwNTgxNDE4OTM=