Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simplify Routes facade methods #1743

Open
caendesilva opened this issue Jun 28, 2024 · 1 comment
Open

Simplify Routes facade methods #1743

caendesilva opened this issue Jun 28, 2024 · 1 comment

Comments

@caendesilva
Copy link
Member

Wondering if we should take more steps to normalize the API, and match to Laravel. I'm not sure if there is ever really a reason to want a null return here, I think if you don't want to catch an exception, it's better to use Routes::exists to check first. See #591 which was closed due to similar motivations

Originally posted by @caendesilva in #1731 (comment)

@caendesilva
Copy link
Member Author

The current methods as follows:

public static function get(string $routeKey): ?Route
{
    return static::getFacadeRoot()->get($routeKey);
}

/** @throws \Hyde\Framework\Exceptions\RouteNotFoundException */
public static function getOrFail(string $routeKey): Route
{
    return static::getFacadeRoot()->getRoute($routeKey);
}

Could be merged and simplified like this:

public static function get(string $routeKey): Route
{
    return static::getFacadeRoot()->getRoute($routeKey);
}

Considering this is quite a BC break for quite a small thing, we would need to carefully consider this

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

No branches or pull requests

1 participant