Skip to content

Instantly share code, notes, and snippets.

@azcdev
Last active December 31, 2015 11:29
Show Gist options
  • Save azcdev/7979954 to your computer and use it in GitHub Desktop.
Save azcdev/7979954 to your computer and use it in GitHub Desktop.
Implementacion de Factory en PHP
<?php
class CarrosFactory {
public function __construct();
public static function crearCarro($tipoMotor, $cilindros) {
switch($tipoMotor) {
case MOTOR::DIESEL:
return new CarroDiesel($cilindros);
break;
case MOTOR::GASOLINA:
return new CarroGasolina($cilindros);
break;
case MOTOR::BIODIESEL:
return new CarroBiodiesel($cilindros);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment