View on GitHub

RefactoringPHP

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

Split Variable (240)

Old Code

<?php
$temp = 2 * ($height + $width);
echo $temp. "\n";
$temp = $height * $width;
echo $temp . "\n";

New Code

<?php
$perimeter = 2 * ($height + $width);
echo $perimeter. "\n";
$area = $height * $width;
echo $area . "\n";