diff options
author | Mario <mario@mariovavti.com> | 2024-02-10 22:04:24 +0000 |
---|---|---|
committer | Mario <mario@mariovavti.com> | 2024-02-10 22:04:24 +0000 |
commit | 7ccb2a261521cc826ff41d91cebbab504b7c4e11 (patch) | |
tree | 043d03fbad8f58352c75ae7e3fb6ae942edb64e9 /vendor/scssphp/scssphp/src/ValueConverter.php | |
parent | 067a66b9278e3c8ff2c624f38f2817715eb8a316 (diff) | |
download | volse-hubzilla-7ccb2a261521cc826ff41d91cebbab504b7c4e11.tar.gz volse-hubzilla-7ccb2a261521cc826ff41d91cebbab504b7c4e11.tar.bz2 volse-hubzilla-7ccb2a261521cc826ff41d91cebbab504b7c4e11.zip |
custom sass bootstrap builds for channels and site
Diffstat (limited to 'vendor/scssphp/scssphp/src/ValueConverter.php')
-rw-r--r-- | vendor/scssphp/scssphp/src/ValueConverter.php | 95 |
1 files changed, 95 insertions, 0 deletions
diff --git a/vendor/scssphp/scssphp/src/ValueConverter.php b/vendor/scssphp/scssphp/src/ValueConverter.php new file mode 100644 index 000000000..e12a0eb54 --- /dev/null +++ b/vendor/scssphp/scssphp/src/ValueConverter.php @@ -0,0 +1,95 @@ +<?php + +/** + * SCSSPHP + * + * @copyright 2012-2020 Leaf Corcoran + * + * @license http://opensource.org/licenses/MIT MIT + * + * @link http://scssphp.github.io/scssphp + */ + +namespace ScssPhp\ScssPhp; + +use ScssPhp\ScssPhp\Node\Number; + +final class ValueConverter +{ + // Prevent instantiating it + private function __construct() + { + } + + /** + * Parses a value from a Scss source string. + * + * The returned value is guaranteed to be supported by the + * Compiler methods for registering custom variables. No other + * guarantee about it is provided. It should be considered + * opaque values by the caller. + * + * @param string $source + * + * @return mixed + */ + public static function parseValue($source) + { + $parser = new Parser(__CLASS__); + + if (!$parser->parseValue($source, $value)) { + throw new \InvalidArgumentException(sprintf('Invalid value source "%s".', $source)); + } + + return $value; + } + + /** + * Converts a PHP value to a Sass value + * + * The returned value is guaranteed to be supported by the + * Compiler methods for registering custom variables. No other + * guarantee about it is provided. It should be considered + * opaque values by the caller. + * + * @param mixed $value + * + * @return mixed + */ + public static function fromPhp($value) + { + if ($value instanceof Number) { + return $value; + } + + if (is_array($value) && isset($value[0]) && \in_array($value[0], [Type::T_NULL, Type::T_COLOR, Type::T_KEYWORD, Type::T_LIST, Type::T_MAP, Type::T_STRING])) { + return $value; + } + + if ($value === null) { + return Compiler::$null; + } + + if ($value === true) { + return Compiler::$true; + } + + if ($value === false) { + return Compiler::$false; + } + + if ($value === '') { + return Compiler::$emptyString; + } + + if (\is_int($value) || \is_float($value)) { + return new Number($value, ''); + } + + if (\is_string($value)) { + return [Type::T_STRING, '"', [$value]]; + } + + throw new \InvalidArgumentException(sprintf('Cannot convert the value of type "%s" to a Sass value.', gettype($value))); + } +} |