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

Contrast should return an int or float? #88

Open
NiklasBr opened this issue Aug 4, 2024 · 0 comments
Open

Contrast should return an int or float? #88

NiklasBr opened this issue Aug 4, 2024 · 0 comments
Assignees

Comments

@NiklasBr
Copy link

NiklasBr commented Aug 4, 2024

Function signature says : float

public static function ratio(Color $a, Color $b): float

but the return value is cast to int:

color/src/Contrast.php

Lines 27 to 31 in 2a3bb4e

if ($l1 > $l2) {
return (int) (($l1 + 0.05) / ($l2 + 0.05));
} else {
return (int) (($l2 + 0.05) / ($l1 + 0.05));
}

It could be improved by changing the return cast to (float), but I am not sure if there are any side effects to I want to ask about what is the intent here before creating a PR.

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

2 participants