Advent of code 2021/5
Ajax Direct

Answer 2245ms

Part 1 : 6572 Part 2 : 21466
function solve($points, $diagonals = false) {
    $lines = [];

    foreach ($points as [$x1, $y1, $x2, $y2]) {
        if ($diagonals || ($x1 == $x2 || $y1 == $y2)) {
            $lines = array_merge($lines, GridPointer::getInbetween([$x1, $y1], [$x2, $y2]));
        }
    }

    return set($lines)->map(fn ($xy) => implode(";", $xy))->duplicates(2)->count();
}

// ==================================================
// > SOLUTIONS
// ==================================================
$points     = $input->numbers()->chunk(4);
$solution_1 = solve($points, false);
$solution_2 = solve($points, true);