View on GitHub

RefactoringPHP

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

Pull Up Method (350)

Inverse of Push Down Method (359)

Old Code

<?php
class Employee
{
    ...
}

class Salesman extends Employee
{
    public function getName()
    {
        ...
    }
}

class Engineer extends Employee
{
    public function getName()
    {
        ...
    }
}

New Code

<?php
class Employee
{
    public function getName()
    {
        ...
    }
}

class Salesman extends Employee
{
    ...
}

class Engineer extends Employee
{
    ...
}