Created
May 12, 2024 10:08
-
-
Save andipyk/a3a137d518b71fd3b28a8722944422eb to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
interface Formatter { | |
public function format(string $input): string; | |
} | |
trait DefaultFormatter { | |
#[\Override] | |
public function format(string $input): string { | |
// Default formatter simply returns the input as is. | |
return $input; | |
} | |
} | |
class CustomFormatter { | |
// Using trait to provide a default implementation. | |
use DefaultFormatter; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment