File "EnumReflectionProperty.php"

Full Path: /home/warrior1/public_html/plugins/mailpoet/vendor-prefixed/doctrine/persistence/src/Persistence/Reflection/EnumReflectionProperty.php
File size: 911 bytes
MIME-type: text/x-php
Charset: utf-8

<?php
namespace MailPoetVendor\Doctrine\Persistence\Reflection;
if (!defined('ABSPATH')) exit;
use BackedEnum;
use ReflectionProperty;
use ReturnTypeWillChange;
class EnumReflectionProperty extends ReflectionProperty
{
 private $originalReflectionProperty;
 private $enumType;
 public function __construct(ReflectionProperty $originalReflectionProperty, string $enumType)
 {
 $this->originalReflectionProperty = $originalReflectionProperty;
 $this->enumType = $enumType;
 }
 #[\ReturnTypeWillChange]
 public function getValue($object = null)
 {
 if ($object === null) {
 return null;
 }
 $enum = $this->originalReflectionProperty->getValue($object);
 if ($enum === null) {
 return null;
 }
 return $enum->value;
 }
 public function setValue($object, $value = null) : void
 {
 if ($value !== null) {
 $value = $this->enumType::from($value);
 }
 $this->originalReflectionProperty->setValue($object, $value);
 }
}