Файл: vendor/intervention/image/src/Modifiers/AbstractDrawModifier.php
Строк: 81
<?php
declare(strict_types=1);
namespace InterventionImageModifiers;
use InterventionImageColor;
use InterventionImageDriversSpecializableModifier;
use InterventionImageExceptionsColorDecoderException;
use InterventionImageExceptionsModifierException;
use InterventionImageExceptionsStateException;
use InterventionImageInterfacesColorInterface;
use InterventionImageInterfacesDrawableInterface;
abstract class AbstractDrawModifier extends SpecializableModifier
{
/**
* Return the drawable object which will be rendered by the modifier.
*/
abstract protected function drawable(): DrawableInterface;
/**
* Return the background color of the object rendered by the modifier.
*
* @throws StateException
* @throws ColorDecoderException
*/
protected function backgroundColor(): ColorInterface
{
$backgroundColor = $this->drawable()->backgroundColor();
if ($backgroundColor === null) {
return Color::transparent();
}
return $this->driver()->decodeColor($backgroundColor);
}
/**
* Return the border color of the object rendered by the modifier.
*
* @throws StateException
* @throws ColorDecoderException
*/
protected function borderColor(): ColorInterface
{
$borderColor = $this->drawable()->borderColor();
if ($borderColor === null || $this->drawable()->hasBorder() === false) {
return Color::transparent();
}
return $this->driver()->decodeColor($borderColor);
}
/**
* Throw ModifierException with given message if result is false.
*
* @throws ModifierException
*/
protected function abortUnless(mixed $result, string $message): void
{
if ($result === false) {
throw new ModifierException(
'Failed to apply ' . self::class . ', ' . $message,
);
}
}
}