diff --git a/Transport/Factory.php b/Transport/Factory.php deleted file mode 100644 index b1cd561..0000000 --- a/Transport/Factory.php +++ /dev/null @@ -1,20 +0,0 @@ -send(); - } - return false; - } -} \ No newline at end of file diff --git a/app/code/Scenario.php b/app/code/Scenario.php new file mode 100644 index 0000000..063825e --- /dev/null +++ b/app/code/Scenario.php @@ -0,0 +1,44 @@ +backup = BackupFactory::build($scenario['backup']); + $this->to = TransportFactory::build($scenario['to']); + } + + + public static function launch($scenario) + { + if (is_readable($scenario)) { + $scenario = json_decode(file_get_contents($scenario), true); + if (static::isValid($scenario)) { + $scenario = new self($scenario); + } + throw new \Exception('invalid scenario.'); + } + throw new \Exception('scenario not found.'); + } + + public static function isValid(\StdClass $scenario) + { + return + isset($scenario->backup) && + count($scenario->backup) === 1 && + isset($scenario->to) && + count($scenario->to) === 1; + } + +} \ No newline at end of file diff --git a/Transport/Abstract.php b/app/code/Transport/Abstract.php similarity index 72% rename from Transport/Abstract.php rename to app/code/Transport/Abstract.php index 86277e5..45c3100 100644 --- a/Transport/Abstract.php +++ b/app/code/Transport/Abstract.php @@ -1,12 +1,16 @@ from@example.net", + "encoding" : "UTF-8", + "subject" : "[Example.net] backup of the day", + "message" : "Hi,\n\nYou can find your backup in this mail.\n\nRegards,\nMyself." + }, + "Ftp": { + "host" : "ftp.domain.com", + "login" : "login", + "password" : "password", + "folder" : "/folder" + } + } +}] \ No newline at end of file diff --git a/app/temp/.gitkeep b/app/temp/.gitkeep new file mode 100644 index 0000000..e69de29