This should shorten it and avoid loading the DBO twice/making 2 separate selects. It's using loadAssoc instead of 2 instances of load result so you can get the individual results in one, targetting the vars from $resultat->value where value is equal to any of the aliases set in the query... Should be a fair bit faster and less overhead...
Obviously, untested as I don't have your db and data so double check I've not mis-spelled anything but, it should work fine:
if ($this->factwork != null) {
$collabId = JFactory::getUser()->get('id');
$maDB = $this->getDbo();
$requete = $maDB->getQuery(true);
$maDB->setQuery
("SELECT w.role AS role, r.rate as rate
FROM #__raptechs_workers w
LEFT JOIN #__raptechs_rates r ON(r.id = w.role)
WHERE w.technicien = $collabId");
$resultat = $maDB->loadAssoc();
$duree = (($this->hfin * 60) + $this->mfin) - (($this->hdeb * 60) + $this->mdeb);
$this->factwork = $resultat->rate / 60 * $duree;
}
Also, I've condensed the lines:
$amount = $rate / 60 * $duree;
$this->factwork = $amount;
as you can see in the last line as I don't see the need to do the calculation, setting it as a local variable, only to set another by it.
Hope it helps,
Gez