mirror of
https://github.com/Chouchen/Shikiryu_Backup.git
synced 2021-06-30 16:02:14 +02:00
Abstraction and factorization
This commit is contained in:
20
Transport/Factory.php
Normal file
20
Transport/Factory.php
Normal 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;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user