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

Use an abstract method instead of a bunch of ifs #3

Closed

Conversation

MidnightDesign
Copy link
Sponsor

No description provided.

@MidnightDesign
Copy link
Sponsor Author

This enables users of the library to implement custom types like Enums:

enum Pet: string {
    case Dog = 'dog';
    case Dragon = 'dragon';
}

final class PetType extends Type
{
    public function cast(string $value): Pet
    {
        return Pet::from($value);
    }
}

@sebastianbergmann
Copy link
Owner

Support for custom types is out of scope for this library.

@codecov
Copy link

codecov bot commented Mar 22, 2023

Codecov Report

Merging #3 (ff2a446) into main (d964d22) will decrease coverage by 13.80%.
The diff coverage is 11.11%.

@@              Coverage Diff               @@
##                main       #3       +/-   ##
==============================================
- Coverage     100.00%   86.20%   -13.80%     
- Complexity        27       28        +1     
==============================================
  Files              8        8               
  Lines             57       58        +1     
==============================================
- Hits              57       50        -7     
- Misses             0        8        +8     
Impacted Files Coverage Δ
src/schema/ColumnDefinition.php 100.00% <ø> (ø)
src/schema/Schema.php 100.00% <ø> (ø)
src/schema/type/BooleanType.php 50.00% <0.00%> (-50.00%) ⬇️
src/schema/type/FloatType.php 50.00% <0.00%> (-50.00%) ⬇️
src/schema/type/IntegerType.php 50.00% <0.00%> (-50.00%) ⬇️
src/schema/type/StringType.php 50.00% <0.00%> (-50.00%) ⬇️
src/schema/type/Type.php 100.00% <ø> (ø)
src/Parser.php 100.00% <100.00%> (ø)

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@MidnightDesign
Copy link
Sponsor Author

Support for custom types is out of scope for this library.

Alright. Still, don't you think this is a nicer way of writing this?

@sebastianbergmann
Copy link
Owner

Still, don't you think this is a nicer way of writing this?

Yes, I do. But I had something even nicer in mind that I just had not gotten to yet.

Thank you for your contribution. I appreciate the time you invested in preparing this pull request. However, I have decided not to merge it.

@MidnightDesign MidnightDesign deleted the cast-method branch March 23, 2023 06:14
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.

None yet

2 participants