public function apply(callable $transform): self
    {
        $result = $transform($this) ?? $this;

        if ($result instanceof self) {
            return $result;
        }

        return $this->handleException(InvalidReturnValueException::create(
            'The transform function return value',
            $result,
            ['null', self::class]
        ));
    }