Abstraction and factorization

This commit is contained in:
Shikiryu
2015-07-09 00:46:17 +02:00
parent 88a5b39d23
commit dbcd02c2af
9 changed files with 208 additions and 86 deletions

20
Transport/Factory.php Normal file
View File

@@ -0,0 +1,20 @@
<?php
class Shikiryu_Backup_Transport_Factory
{
/**
* @param $type
* @param Shikiryu_Backup_Abstract $backup
*
* @return bool
*/
public static function getAndSend($type, Shikiryu_Backup_Abstract $backup, $args = null) {
$class = sprintf('Shikiryu_Backup_Transport_%s', ucfirst($type));
if (class_exists($class)) {
/* @var $instance Shikiryu_Backup_Transport_Abstract */
$instance = new $class($backup, $args);
return $instance->send();
}
return false;
}
}