Are there specific PHP functions or libraries that can be utilized to simplify the process of calculating discounts in scenarios similar to the Harry-Potter Programmier test?

To simplify the process of calculating discounts in scenarios similar to the Harry-Potter Programmier test, you can utilize the `array_count_values` function in PHP to count the occurrences of each book in the basket. Then, you can create a discount logic based on the number of unique books in the basket.

function calculateDiscount($basket) {
    $bookCounts = array_count_values($basket);
    $totalBooks = count($basket);
    $uniqueBooks = count($bookCounts);

    $discount = 0;
    switch ($uniqueBooks) {
        case 2:
            $discount = $totalBooks * 0.05;
            break;
        case 3:
            $discount = $totalBooks * 0.1;
            break;
        case 4:
            $discount = $totalBooks * 0.2;
            break;
        case 5:
            $discount = $totalBooks * 0.25;
            break;
    }

    return $discount;
}

$basket = ['Book1', 'Book2', 'Book1', 'Book3', 'Book4', 'Book5'];
$discount = calculateDiscount($basket);
echo "Discount: $discount";