PHP code example of athwari / laravel-method-overrider
1. Go to this page and download the library: Download athwari/laravel-method-overrider library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
athwari / laravel-method-overrider example snippets
return [
'ignore_final_methods' => true,
];
use Athwari\MethodOverrider\Facades\MethodOverrider;
class TestService
{
public function greet(string $name): string
{
return "Hello {$name}";
}
}
$service = MethodOverrider::override(
TestService::class,
'greet',
function ($original, $name) {
return strtoupper($original($name));
}
);
echo $service->greet('Taylor'); // HELLO TAYLOR