Why this matters
Single source of truth reduces bugs and improves testability.
Move repeated domain calculations/transformations into named functions or service classes; keep controllers/scripts thin.
Single source of truth reduces bugs and improves testability.
Side-by-side examples engineers can pattern-match during review.
$total += $item['price'] * $item['qty']; // repeated in multiple filesfunction lineTotal(array $i): float { return $i['price'] * $i['qty']; }
$total = array_sum(array_map('lineTotal', $items));$a['p']*$a['q']function lineTotal($i){ return $i['p']*$i['q']; }From the same buckets as this rule.