How can I optimize the code provided for better readability and maintainability in a PHP project?

To optimize the code for better readability and maintainability in a PHP project, you can break down the code into smaller, more modular functions, use meaningful variable names, add comments to explain complex logic, and adhere to coding standards like PSR-12.

// Original code snippet
function calculateTotalPrice($price, $quantity) {
    $discount = 0.1;
    $total = $price * $quantity;
    if ($total > 100) {
        $total = $total * (1 - $discount);
    }
    return $total;
}
```

```php
// Optimized code snippet
function calculateTotalPrice($price, $quantity) {
    $discount = 0.1;
    $total = calculateSubtotal($price, $quantity);
    
    if ($total > 100) {
        $total = applyDiscount($total, $discount);
    }
    
    return $total;
}

function calculateSubtotal($price, $quantity) {
    return $price * $quantity;
}

function applyDiscount($total, $discount) {
    return $total * (1 - $discount);
}