Commits

Arie W. Subagja committed 59db429

abstract converter

Comments (0)

Files changed (3)

+/nbproject/

classes/converter.php

+<?php
+
+defined('SYSPATH') or die('No direct script access.');
+
+/**
+ * @author  arie
+ */
+
+abstract class Converter extends Cumi_Converter
+{}

classes/cumi/converter.php

+<?php
+
+defined('SYSPATH') or die('No direct script access.');
+
+/**
+ * @author  arie
+ */
+
+abstract class Cumi_Converter
+{
+    /**
+     * Converter Factory
+     *
+     * @param   string      $component
+     * @return  Converter
+     */
+    public static function factory($component)
+    {
+        $class = 'Converter_'. $component;
+        $class = new $class();
+
+        if (! ($class instanceof Converter))
+        {
+            throw new Kohana_Exception('Unknown converter: :component', array(
+                ':component' => $component
+            ));
+        }
+
+        return $class;
+    }
+
+    public function __construct()
+    {}
+
+    /**
+     * Run the converter
+     *
+     * @return void
+     */
+    public function run()
+    {
+        $this->_run();
+    }
+
+    /**
+     * Revert converter
+     *
+     * @return void
+     */
+    public function revert()
+    {
+        $this->_revert();
+    }
+
+    abstract protected function _run();
+
+    abstract protected function _revert();
+}