Файл: vendor/intervention/image/src/Modifiers/ColorspaceModifier.php
Строк: 45
<?php
declare(strict_types=1);
namespace InterventionImageModifiers;
use InterventionImageInterfacesColorspaceInterface;
use InterventionImageColorsCmykColorspace as CmykColorspace;
use InterventionImageColorsRgbColorspace as RgbColorspace;
use InterventionImageDriversSpecializableModifier;
use InterventionImageExceptionsNotSupportedException;
class ColorspaceModifier extends SpecializableModifier
{
public function __construct(public string|ColorspaceInterface $target)
{
}
/**
* @throws NotSupportedException
*/
public function targetColorspace(): ColorspaceInterface
{
if (is_object($this->target)) {
return $this->target;
}
if (in_array($this->target, ['rgb', 'RGB', RgbColorspace::class])) {
return new RgbColorspace();
}
if (in_array($this->target, ['cmyk', 'CMYK', CmykColorspace::class])) {
return new CmykColorspace();
}
throw new NotSupportedException('Given colorspace is not supported.');
}
}