Skip to content

Instantly share code, notes, and snippets.

@bobmagicii
Last active October 12, 2024 07:14
Show Gist options
  • Save bobmagicii/f2d2c49f44ef50d8efe28bff6ec3222d to your computer and use it in GitHub Desktop.
Save bobmagicii/f2d2c49f44ef50d8efe28bff6ec3222d to your computer and use it in GitHub Desktop.
<?php
$GetValueCSS = (fn(?string $Input)=> match(TRUE) {
(str_starts_with($Input, '--'))
=> sprintf('var(%s)', $Input),
(!!preg_match('/^[0-9a-fA-F]{6,8}/', $Input))
=> sprintf('#%s', $Input),
default
=> $Input
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment