View on GitHub

RefactoringPHP

A PHP version of the refactors from Refactoring: Improving the Design of Existing Code (Second Edition) by Martin Fowler

Introduce Special Case (289)

Old Code

<?php
if ( $aCustomer === 'unknown' ) {
    $customerName = 'occupant';
}

New Code

<?php
class UnknownCustomer
{
    public function getName()
    {
        return 'occupant';
    }
}