@klm113 Why not actually fix the problem instead of “hacking” your way around it?
Change the method to be agnostic on how it receives its data. Instead of expecting a request, have it just receive an array of data if that’s what it needs. Then you can use it with a request or data from your other source.
Writing “hacks”—especially to “synthesise” building a request—is just going to make your code less flexible and harder to work with.
@MARTINBEAN Because it's a project where I already spent the development time the customer paid for, I was looking for a quick fix to get working a change they wanted to add in the last minute.
Also, I'm not sure how hacky can this be, seems to be pretty straightforward.
@klm113 Then tell you customer how much it will take to accommodate their last minute change properly.
seems to be pretty straightforward.
If it was straightforward then you wouldn’t be asking here ;)
You have a duty to deliver a quality project to your paying client. So refactor your code to make it reusable with a data source other than a form request like you need it to be.
@klm113 You could spend your time actually rewriting your code instead of spending it arguing with me on here…
It’s “hacky” because you’re asking how to create a “fake” request to pass to your class, instead of just modifying your class to not expect a request and instead just accept the data it needs, no matter the source.
@klm113 I’ve given you reasons why it’s “hacky“. You just seem to be upset I’ve suggested you actually fix the problem instead of giving you a block of code to “quick fix” your way around situation.
Given you opened this thread nearly 24 hours ago, a better use of your time would have been to actually refactor your code to accommodate your predicament instead of arguing with me. You’ve wasted both your time and your paying customer’s time in doing so.