1
0
mirror of https://github.com/Intervention/image.git synced 2025-01-17 12:18:14 +01:00

Refactor get_class() to class constant

This commit is contained in:
Oliver Vogel 2024-01-31 16:56:12 +01:00
parent b091516b09
commit ca73572e44
No known key found for this signature in database
GPG Key ID: 1B19D214C02D69BB
9 changed files with 10 additions and 10 deletions

View File

@ -24,7 +24,7 @@ abstract class AbstractColor implements ColorInterface
public function channel(string $classname): ColorChannelInterface
{
$channels = array_filter($this->channels(), function (ColorChannelInterface $channel) use ($classname) {
return get_class($channel) == $classname;
return $channel::class == $classname;
});
if (count($channels) == 0) {

View File

@ -42,7 +42,7 @@ class Colorspace implements ColorspaceInterface
*/
public function importColor(ColorInterface $color): ColorInterface
{
return match (get_class($color)) {
return match ($color::class) {
RgbColor::class => $this->importRgbColor($color),
HsvColor::class => $this->importRgbColor($color->convertTo(RgbColorspace::class)),
HslColor::class => $this->importRgbColor($color->convertTo(RgbColorspace::class)),

View File

@ -35,7 +35,7 @@ class Colorspace implements ColorspaceInterface
public function importColor(ColorInterface $color): ColorInterface
{
return match (get_class($color)) {
return match ($color::class) {
CmykColor::class => $this->importRgbColor($color->convertTo(RgbColorspace::class)),
RgbColor::class => $this->importRgbColor($color),
HsvColor::class => $this->importHsvColor($color),

View File

@ -40,7 +40,7 @@ class Colorspace implements ColorspaceInterface
*/
public function importColor(ColorInterface $color): ColorInterface
{
return match (get_class($color)) {
return match ($color::class) {
CmykColor::class => $this->importRgbColor($color->convertTo(RgbColorspace::class)),
RgbColor::class => $this->importRgbColor($color),
HslColor::class => $this->importHslColor($color),

View File

@ -40,7 +40,7 @@ class Colorspace implements ColorspaceInterface
*/
public function importColor(ColorInterface $color): ColorInterface
{
return match (get_class($color)) {
return match ($color::class) {
CmykColor::class => $this->importCmykColor($color),
HsvColor::class => $this->importHsvColor($color),
HslColor::class => $this->importHslColor($color),

View File

@ -33,7 +33,7 @@ abstract class AbstractDriver implements DriverInterface
}
$driver_namespace = (new ReflectionClass($this))->getNamespaceName();
$class_path = substr(get_class($object), strlen("Intervention\\Image\\"));
$class_path = substr($object::class, strlen("Intervention\\Image\\"));
$classname = $driver_namespace . "\\" . $class_path;
if (!class_exists($classname)) {

View File

@ -36,7 +36,7 @@ abstract class AbstractInputHandler implements InputHandlerInterface
protected function chain(): AbstractDecoder
{
if (count($this->decoders) == 0) {
throw new DecoderException('No decoders found in ' . get_class($this));
throw new DecoderException('No decoders found in ' . $this::class);
}
// get instance of last decoder in stack

View File

@ -26,7 +26,7 @@ class ColorProcessor implements ColorProcessorInterface
public function nativeToColor(mixed $native): ColorInterface
{
return match (get_class($this->colorspace)) {
return match ($this->colorspace::class) {
CmykColorspace::class => $this->colorspace->colorFromNormalized([
$native->getColorValue(Imagick::COLOR_CYAN),
$native->getColorValue(Imagick::COLOR_MAGENTA),

View File

@ -37,10 +37,10 @@ class ColorspaceModifier extends DriverSpecialized implements ModifierInterface
private function getImagickColorspace(ColorspaceInterface $colorspace): int
{
if (!array_key_exists(get_class($colorspace), self::$mapping)) {
if (!array_key_exists($colorspace::class, self::$mapping)) {
throw new NotSupportedException('Given colorspace is not supported.');
}
return self::$mapping[get_class($colorspace)];
return self::$mapping[$colorspace::class];
}
}