public function addUnit(Unit $unit) { if ($unit instanceof Cavalry) { throw new Exception("can't get a horse on the vehicle"); } parent::addUnit($unit); }
function addUnit(Unit $unit) { if ($unit instanceof Cavalry) { throw new UnitException("Нельзя помещать лошадь на бронетранспортер"); } parent::addUnit($unit); }
public function __construct(CompositeUnit $compositeUnit) { $this->units = $compositeUnit->units(); }