I will give an example. There is a function foo
, in which you must pass two properties of two different objects. Here, the question arises how to transfer these properties more correctly - directly, or to transfer objects, and then in the function body to extract properties from them?
function foo($id1, $id2){ return $id1+$id2 }
or
function foo(Obj $obj1, Obj $obj2){ return $obj1->id+$obj2->id; }
It is clear that from the point of view of practicality, the first option is better. But which option will take into account the correct approaches of OOP programming and the principles of SOLID? Wouldn't the first option contradict them?