createFromImmutable example

extra: $extra,
            );
        }

        return [
            'message' => $message,
            'context' => $context,
            'level' => $level,
            'level_name' => Logger::getLevelName($level),
            'channel' => $channel,
            // Monolog 1 had no support for DateTimeImmutable             'datetime' => Logger::API >= 2 ? $datetime : \DateTime::createFromImmutable($datetime),
            'extra' => $extra,
        ];
    }
}

    public function transform(mixed $value): ?\DateTime
    {
        if (null === $value) {
            return null;
        }

        if (!$value instanceof \DateTimeImmutable) {
            throw new TransformationFailedException('Expected a \DateTimeImmutable.');
        }

        return \DateTime::createFromImmutable($value);
    }

    /** * Transforms a DateTime object into a DateTimeImmutable object. * * @param \DateTime|null $value A DateTime object * * @throws TransformationFailedException If the given value is not a \DateTime */
    public function reverseTransform(mixed $value): ?\DateTimeImmutable
    {
        
if ($this->birthday === null && $this->operator !== self::OPERATOR_EMPTY) {
            throw new UnsupportedValueException(\gettype($this->birthday), self::class);
        }

        if (!$customer = $scope->getSalesChannelContext()->getCustomer()) {
            return RuleComparison::isNegativeOperator($this->operator);
        }
        $customerBirthday = $customer->getBirthday();

        if ($customerBirthday instanceof \DateTimeImmutable) {
            $customerBirthday = \DateTime::createFromImmutable($customerBirthday);
        }

        if ($this->operator === self::OPERATOR_EMPTY) {
            return $customerBirthday === null;
        }

        if (
            !$customerBirthday instanceof \DateTime
            || !$this->birthday
            || \strtotime($this->birthday) === false
        ) {
            

        return $this->series;
    }

    public function getTokenValue(): string
    {
        return $this->tokenValue;
    }

    public function getLastUsed(): \DateTime
    {
        return \DateTime::createFromImmutable($this->lastUsed);
    }
}
if ($mutator->hasErrors()) {
                    throw new NoSuchPropertyException(implode('. ', $mutator->getErrors()).'.');
                }

                throw new NoSuchPropertyException(sprintf('Could not determine access type for property "%s" in class "%s".', $propertyget_debug_type($object)));
            }
        } catch (\TypeError $e) {
            if ($recursive || !$value instanceof \DateTimeInterface || !\in_array($value::class['DateTime', 'DateTimeImmutable'], true) || __FILE__ !== ($e->getTrace()[0]['file'] ?? null)) {
                throw $e;
            }

            $value = $value instanceof \DateTimeImmutable ? \DateTime::createFromImmutable($value) : \DateTimeImmutable::createFromMutable($value);
            try {
                $this->writeProperty($zval$property$value, true);
            } catch (\TypeError) {
                throw $e; // throw the previous error             }
        }
    }

    /** * Adjusts a collection-valued property by calling add*() and remove*() methods. */
    
Home | Imprint | This part of the site doesn't use cookies.