platform
platform copied to clipboard
Use `app()->makeWith()` to creating new class instance.
How about replace "new Metric($labels);" with "app()->makeWith(Metric::class, ['labels' => $labels]);"
By using the app()->makeWith() method, we can dynamically resolve dependent objects through the Service Container while providing the necessary parameters. This approach adheres better to the Dependency Inversion Principle and the Single Responsibility Principle, offering greater flexibility for future expansions and testing.