Skip to content

Instantly share code, notes, and snippets.

@mangelsnc
Last active December 3, 2017 23:48
Factory Pattern - Before apply pattern
<?php
class CarInformation
{
public function getTitle($code)
{
switch ($code) {
case 'HC':
$vendor = 'Honda';
$model = 'Civic';
$engine = '1.5 VTEC Turbo';
$cv = 182;
break;
case 'FF':
$vendor = 'Ford';
$model = 'Focus';
$engine = '1.0 Ecoboost';
$cv = 125;
break;
case 'TA':
$vendor = 'Toyota';
$model = 'Auris';
$engine = 'Auris 120 T';
$cv = 116;
break;
}
return sprintf(
'<b>Model: <\b>\t %s %s\n<b>Engine: <\b>\t %s %sCV',
$vendor, $model, $engine, $cv
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment