, . , , ? , Service/Controller, ?
function processSomething(Person $person, Car $car) {}
. . , , .
, :
public function __construct(array $personList) {
if (count($personList) < 1) {
throw new Exception('No person given');
}
foreach ($personList as $person) {
if (!$person instanceof Person) {
throw new Exception('This is not a person');
}
}
$this->personList = $personList;
}
: , ContainerObject:
class ContainerObject {
public $person;
public $moreInfo;
public $manyMoreInfo;
}
class Person {
public function sayHello() {};
}
class Car {
private $containerObj;
function __construct(ContainerObject $obj) {
$this->containerObj= $obj;
}
function foo() {
$this->containerObj->person->sayHello();
}
}