Enable Discovery debug logging for production troubleshooting
- Add DISCOVERY_LOG_LEVEL=debug - Add DISCOVERY_SHOW_PROGRESS=true - Temporary changes for debugging InitializerProcessor fixes on production
This commit is contained in:
89
src/Framework/Design/ValueObjects/CustomProperty.php
Normal file
89
src/Framework/Design/ValueObjects/CustomProperty.php
Normal file
@@ -0,0 +1,89 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Framework\Design\ValueObjects;
|
||||
|
||||
/**
|
||||
* Repräsentiert eine CSS Custom Property (CSS Variable)
|
||||
*/
|
||||
final readonly class CustomProperty
|
||||
{
|
||||
public function __construct(
|
||||
public string $name,
|
||||
public string $value
|
||||
) {
|
||||
}
|
||||
|
||||
public static function fromDeclaration(string $declaration): self
|
||||
{
|
||||
// Parse "--property-name: value" format
|
||||
if (preg_match('/--([^:]+):\s*([^;]+)/', $declaration, $matches)) {
|
||||
return new self(trim($matches[1]), trim($matches[2]));
|
||||
}
|
||||
|
||||
throw new \InvalidArgumentException('Invalid CSS custom property declaration');
|
||||
}
|
||||
|
||||
public function hasValueType(string $type): bool
|
||||
{
|
||||
return match($type) {
|
||||
'color' => $this->isColorValue(),
|
||||
'size' => $this->isSizeValue(),
|
||||
'number' => $this->isNumberValue(),
|
||||
default => false
|
||||
};
|
||||
}
|
||||
|
||||
public function getValueAs(string $type): mixed
|
||||
{
|
||||
return match($type) {
|
||||
'color' => $this->getColorValue(),
|
||||
'size' => $this->getSizeValue(),
|
||||
'number' => $this->getNumberValue(),
|
||||
default => $this->value
|
||||
};
|
||||
}
|
||||
|
||||
private function isColorValue(): bool
|
||||
{
|
||||
return preg_match('/^(#[0-9a-fA-F]{3,8}|rgb|hsl|oklch|color)/', $this->value) === 1;
|
||||
}
|
||||
|
||||
private function isSizeValue(): bool
|
||||
{
|
||||
return preg_match('/^\d+(\.\d+)?(px|em|rem|%|vh|vw)$/', $this->value) === 1;
|
||||
}
|
||||
|
||||
private function isNumberValue(): bool
|
||||
{
|
||||
return is_numeric($this->value);
|
||||
}
|
||||
|
||||
private function getColorValue(): CssColor
|
||||
{
|
||||
if ($this->isColorValue()) {
|
||||
$format = match(true) {
|
||||
str_starts_with($this->value, '#') => ColorFormat::HEX,
|
||||
str_starts_with($this->value, 'rgb') => ColorFormat::RGB,
|
||||
str_starts_with($this->value, 'hsl') => ColorFormat::HSL,
|
||||
str_starts_with($this->value, 'oklch') => ColorFormat::OKLCH,
|
||||
default => ColorFormat::HEX
|
||||
};
|
||||
|
||||
return new CssColor($this->value, $format);
|
||||
}
|
||||
|
||||
throw new \InvalidArgumentException('Value is not a color');
|
||||
}
|
||||
|
||||
private function getSizeValue(): string
|
||||
{
|
||||
return $this->value;
|
||||
}
|
||||
|
||||
private function getNumberValue(): float
|
||||
{
|
||||
return (float) $this->value;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user