G
G
gog692016-09-15 00:31:37
symfony
gog69, 2016-09-15 00:31:37

How to add a method to a class if the class cannot be overridden?

different application services return objects of different types
$searchResults
$someOtherResults
$arrayOfValueObjects
if there is no way to override them, how to make them "reduce to a common denominator"

foreach(array_merge($searchResults, $someOtherResults, $arrayOfValueObjects) as $item) {
     $item->render();
}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey, 2016-09-15
Protko @Fesor

wrap the work with these services in another service that will actually act as a facade and hide all the dirt that you are doing so that it would be convenient.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question