Skip to content

Conversation

@UniForceMusic
Copy link
Contributor

@UniForceMusic UniForceMusic commented Dec 9, 2025

As a proposed solution to #89

Syntax goes as follows:

// If Else
caseStatement()
    ->when($criteria, $result)
    ->when($criteria, $result)
    ->else($result);

// Switch
caseStatement($expression)
    ->when($expression, $result)
    ->when($expression, $result)
    ->else($result);

This syntax compiles to:

-- If Else
CASE 
    WHEN field = ? THEN ?
    WHEN field = ? THEN ? 
    ELSE ?
END

-- Switch
CASE ?
    WHEN ? THEN ?
    WHEN ? THEN ? 
    ELSE ?
END

NOTE:
Cannot use case() as a function or method name because it's a reserved keyword. That's why it's caseStatement()

@UniForceMusic UniForceMusic mentioned this pull request Dec 9, 2025
@UniForceMusic UniForceMusic changed the title CASE WHEN ELSE END statement [ISSUE-FIX] CASE WHEN ELSE END statement Dec 9, 2025
@UniForceMusic UniForceMusic marked this pull request as ready for review December 10, 2025 10:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant