/** * Returns the gap between this lap sector and given lap sector * * @param Lap $lap * @param int $sector * @return float|null */ public function getSectorGap(Lap $lap, $sector) { // Get sectors $this_sectors = $this->getSectorTimes(); $lap_sectors = $lap->getSectorTimes(); // Define array sector index $sector_index = $sector - 1; // Given lap or thos lap has no sector time if (!isset($lap_sectors[$sector_index]) or !isset($this_sectors[$sector_index])) { return null; } // Return difference and round to 4 to fix floats return round($lap_sectors[$sector_index] - $this_sectors[$sector_index], 4); }