From b8bcadb6bb07ed276b89824ca8fbdb6f0997f0c9 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Guillaume=20Perr=C3=A9al?= <guillaume.perreal@irstea.fr>
Date: Wed, 9 Mar 2016 13:08:27 +0100
Subject: [PATCH] Refactoring: Uml*Interface => Writable*Interface.

---
 Model/AbstractNamespace.php                   |  9 +++++----
 Model/Arrow/BaseArrow.php                     | 12 +++++------
 Model/Arrow/ExtendsClass.php                  |  4 ++--
 Model/Arrow/ImplementsInterface.php           |  4 ++--
 Model/Arrow/UsesTrait.php                     |  4 ++--
 Model/ArrowInterface.php                      | 20 +++++++++++++++++++
 Model/ClassVisitor.php                        | 10 ++++++----
 Model/ClassVisitorInterface.php               |  2 +-
 Model/NamespaceInterface.php                  | 12 ++++++-----
 Model/Namespace_.php                          |  4 ++--
 Model/Node/BaseNode.php                       | 12 ++---------
 Model/NodeInterface.php                       | 20 +++++++++++++++++++
 Model/RootNamespace.php                       | 10 ++++++----
 .../WritableArrowInterface.php                |  4 ++--
 .../WritableInterface.php                     |  4 ++--
 .../WritableNodeInterface.php                 |  4 ++--
 16 files changed, 87 insertions(+), 48 deletions(-)
 create mode 100644 Model/ArrowInterface.php
 create mode 100644 Model/NodeInterface.php
 rename Model/UmlArrowInterface.php => Writer/WritableArrowInterface.php (65%)
 rename Model/UmlComponentInterface.php => Writer/WritableInterface.php (83%)
 rename Model/UmlNodeInterface.php => Writer/WritableNodeInterface.php (78%)

diff --git a/Model/AbstractNamespace.php b/Model/AbstractNamespace.php
index 783846d..5cc0538 100644
--- a/Model/AbstractNamespace.php
+++ b/Model/AbstractNamespace.php
@@ -8,6 +8,7 @@
 
 namespace Irstea\PlantUmlBundle\Model;
 
+use Irstea\PlantUmlBundle\Writer\WritableInterface;
 use Irstea\PlantUmlBundle\Writer\WriterInterface;
 
 /**
@@ -15,10 +16,10 @@ use Irstea\PlantUmlBundle\Writer\WriterInterface;
  *
  * @author Guillaume Perréal <guillaume.perreal@irstea.fr>
  */
-abstract class AbstractNamespace implements UmlComponentInterface, NamespaceInterface
+abstract class AbstractNamespace implements WritableInterface, NamespaceInterface
 {
     /**
-     * @var UmlNodeInterface[]
+     * @var NodeInterface[]
      */
     private $nodes = [];
 
@@ -29,9 +30,9 @@ abstract class AbstractNamespace implements UmlComponentInterface, NamespaceInte
 
     /**
      *
-     * @param UmlNodeInterface $node
+     * @param NodeInterface $node
      */
-    public function addNode(UmlNodeInterface $node)
+    public function addNode(NodeInterface $node)
     {
         $this->nodes[] = $node;
         return $this;
diff --git a/Model/Arrow/BaseArrow.php b/Model/Arrow/BaseArrow.php
index 5ba6bc8..f281c23 100644
--- a/Model/Arrow/BaseArrow.php
+++ b/Model/Arrow/BaseArrow.php
@@ -8,8 +8,8 @@
 
 namespace Irstea\PlantUmlBundle\Model\Arrow;
 
-use Irstea\PlantUmlBundle\Model\UmlArrowInterface;
-use Irstea\PlantUmlBundle\Model\UmlNodeInterface;
+use Irstea\PlantUmlBundle\Model\ArrowInterface;
+use Irstea\PlantUmlBundle\Model\NodeInterface;
 use Irstea\PlantUmlBundle\Writer\WriterInterface;
 
 /**
@@ -17,15 +17,15 @@ use Irstea\PlantUmlBundle\Writer\WriterInterface;
  *
  * @author Guillaume Perréal <guillaume.perreal@irstea.fr>
  */
-class BaseArrow implements UmlArrowInterface
+class BaseArrow implements ArrowInterface
 {
     /**
-     * @var UmlNodeInterface
+     * @var NodeInterface
      */
     private $source;
 
     /**
-     * @var UmlNodeInterface
+     * @var NodeInterface
      */
     private $target;
 
@@ -34,7 +34,7 @@ class BaseArrow implements UmlArrowInterface
      */
     private $link;
 
-    public function __construct(UmlNodeInterface $source, UmlNodeInterface $target, $link = "--", $label = null)
+    public function __construct(NodeInterface $source, NodeInterface $target, $link = "--", $label = null)
     {
         $this->source = $source;
         $this->target = $target;
diff --git a/Model/Arrow/ExtendsClass.php b/Model/Arrow/ExtendsClass.php
index 9a0c0d6..28aa52b 100644
--- a/Model/Arrow/ExtendsClass.php
+++ b/Model/Arrow/ExtendsClass.php
@@ -8,7 +8,7 @@
 
 namespace Irstea\PlantUmlBundle\Model\Arrow;
 
-use Irstea\PlantUmlBundle\Model\UmlNodeInterface;
+use Irstea\PlantUmlBundle\Writer\WritableNodeInterface;
 
 /**
  * Description of ExtendsClass
@@ -17,7 +17,7 @@ use Irstea\PlantUmlBundle\Model\UmlNodeInterface;
  */
 class ExtendsClass extends BaseArrow
 {
-    public function __construct(UmlNodeInterface $source, UmlNodeInterface $target)
+    public function __construct(WritableNodeInterface $source, WritableNodeInterface $target)
     {
         parent::__construct($target, $source, "<|--");
     }
diff --git a/Model/Arrow/ImplementsInterface.php b/Model/Arrow/ImplementsInterface.php
index bd7451b..ad51562 100644
--- a/Model/Arrow/ImplementsInterface.php
+++ b/Model/Arrow/ImplementsInterface.php
@@ -9,7 +9,7 @@
 namespace Irstea\PlantUmlBundle\Model\Arrow;
 
 use Irstea\PlantUmlBundle\Model\Node\Interface_;
-use Irstea\PlantUmlBundle\Model\UmlNodeInterface;
+use Irstea\PlantUmlBundle\Writer\WritableNodeInterface;
 
 /**
  * Description of ImplementsInterface
@@ -18,7 +18,7 @@ use Irstea\PlantUmlBundle\Model\UmlNodeInterface;
  */
 class ImplementsInterface extends BaseArrow
 {
-    public function __construct(UmlNodeInterface $source, Interface_ $target)
+    public function __construct(WritableNodeInterface $source, Interface_ $target)
     {
         parent::__construct($target, $source, "<|..");
     }
diff --git a/Model/Arrow/UsesTrait.php b/Model/Arrow/UsesTrait.php
index 9d59279..ce564c0 100644
--- a/Model/Arrow/UsesTrait.php
+++ b/Model/Arrow/UsesTrait.php
@@ -9,7 +9,7 @@
 namespace Irstea\PlantUmlBundle\Model\Arrow;
 
 use Irstea\PlantUmlBundle\Model\Node\Trait_;
-use Irstea\PlantUmlBundle\Model\UmlNodeInterface;
+use Irstea\PlantUmlBundle\Writer\WritableNodeInterface;
 
 /**
  * Description of UseTrait
@@ -18,7 +18,7 @@ use Irstea\PlantUmlBundle\Model\UmlNodeInterface;
  */
 class UsesTrait extends BaseArrow
 {
-    public function __construct(UmlNodeInterface $source, Trait_ $trait)
+    public function __construct(WritableNodeInterface $source, Trait_ $trait)
     {
         parent::__construct($trait, $source, "<|--");
     }
diff --git a/Model/ArrowInterface.php b/Model/ArrowInterface.php
new file mode 100644
index 0000000..8180084
--- /dev/null
+++ b/Model/ArrowInterface.php
@@ -0,0 +1,20 @@
+<?php
+
+/*
+ * © 2016 IRSTEA
+ * Guillaume Perréal <guillaume.perreal@irstea.fr>
+ * Tous droits réservés.
+ */
+
+namespace Irstea\PlantUmlBundle\Model;
+
+use Irstea\PlantUmlBundle\Writer\WritableArrowInterface;
+
+/**
+ *
+ * @author Guillaume Perréal <guillaume.perreal@irstea.fr>
+ */
+interface ArrowInterface extends WritableArrowInterface
+{
+    //put your code here
+}
diff --git a/Model/ClassVisitor.php b/Model/ClassVisitor.php
index 08553b6..f3017f5 100644
--- a/Model/ClassVisitor.php
+++ b/Model/ClassVisitor.php
@@ -11,6 +11,8 @@ namespace Irstea\PlantUmlBundle\Model;
 use Irstea\PlantUmlBundle\Model\Node\Class_;
 use Irstea\PlantUmlBundle\Model\Node\Interface_;
 use Irstea\PlantUmlBundle\Model\Node\Trait_;
+use Irstea\PlantUmlBundle\Writer\WritableInterface;
+use Irstea\PlantUmlBundle\Writer\WritableNodeInterface;
 use Irstea\PlantUmlBundle\Writer\WriterInterface;
 use ReflectionClass;
 
@@ -19,7 +21,7 @@ use ReflectionClass;
  *
  * @author Guillaume Perréal <guillaume.perreal@irstea.fr>
  */
-class ClassVisitor implements ClassVisitorInterface, UmlComponentInterface
+class ClassVisitor implements ClassVisitorInterface, WritableInterface
 {
     /**
      * @var RootNamespace
@@ -44,7 +46,7 @@ class ClassVisitor implements ClassVisitorInterface, UmlComponentInterface
     /**
      *
      * @param string $className
-     * @return UmlNodeInterface
+     * @return NodeInterface
      */
     protected function doVisitClass($className)
     {
@@ -54,7 +56,7 @@ class ClassVisitor implements ClassVisitorInterface, UmlComponentInterface
 
     /**
      * @param ReflectionClass $class
-     * @return UmlNodeInterface
+     * @return NodeInterface
      */
     protected function visitClassReflection(ReflectionClass $class)
     {
@@ -98,7 +100,7 @@ class ClassVisitor implements ClassVisitorInterface, UmlComponentInterface
         return $node;
     }
 
-    protected function visitRelations(UmlNodeInterface $source, NamespaceInterface $namespace, array $classNames, $relationClass)
+    protected function visitRelations(WritableNodeInterface $source, NamespaceInterface $namespace, array $classNames, $relationClass)
     {
         foreach ($classNames as $className) {
             $target = $this->visitClass($className);
diff --git a/Model/ClassVisitorInterface.php b/Model/ClassVisitorInterface.php
index 6afc61e..9107120 100644
--- a/Model/ClassVisitorInterface.php
+++ b/Model/ClassVisitorInterface.php
@@ -15,7 +15,7 @@ namespace Irstea\PlantUmlBundle\Model;
 interface ClassVisitorInterface
 {
     /**
-     * @return UmlNodeInterface
+     * @return NodeInterface
      */
     public function visitClass($className);
 }
diff --git a/Model/NamespaceInterface.php b/Model/NamespaceInterface.php
index 1a1e01a..b2639d1 100644
--- a/Model/NamespaceInterface.php
+++ b/Model/NamespaceInterface.php
@@ -8,11 +8,13 @@
 
 namespace Irstea\PlantUmlBundle\Model;
 
+use Irstea\PlantUmlBundle\Writer\WritableInterface;
+
 /**
  *
  * @author Guillaume Perréal <guillaume.perreal@irstea.fr>
  */
-interface NamespaceInterface
+interface NamespaceInterface extends WritableInterface
 {
     /**
      * @param string $namespaceName
@@ -21,14 +23,14 @@ interface NamespaceInterface
     public function getNamespace($namespaceName);
 
     /**
-     * @param UmlNodeInterface $node
+     * @param NodeInterface $node
      * @return self
      */
-    public function addNode(UmlNodeInterface $node);
+    public function addNode(NodeInterface $node);
 
     /**
-     * @param UmlArrowInterface $arrow
+     * @param ArrowInterface $arrow
      * @return self
      */
-    public function addArrow(UmlArrowInterface $arrow);
+    public function addArrow(ArrowInterface $arrow);
 }
diff --git a/Model/Namespace_.php b/Model/Namespace_.php
index 09d4f32..0b504ca 100644
--- a/Model/Namespace_.php
+++ b/Model/Namespace_.php
@@ -34,10 +34,10 @@ class Namespace_ extends AbstractNamespace
     }
 
         /**
-     * @param UmlArrowInterface $arrow
+     * @param ArrowInterface $arrow
      * @return self
      */
-    public function addArrow(UmlArrowInterface $arrow)
+    public function addArrow(ArrowInterface $arrow)
     {
         $this->parent->addArrow($arrow);
         return $this;
diff --git a/Model/Node/BaseNode.php b/Model/Node/BaseNode.php
index 5c766dc..aa60ea4 100644
--- a/Model/Node/BaseNode.php
+++ b/Model/Node/BaseNode.php
@@ -8,7 +8,7 @@
 
 namespace Irstea\PlantUmlBundle\Model\Node;
 
-use Irstea\PlantUmlBundle\Model\UmlNodeInterface;
+use Irstea\PlantUmlBundle\Model\NodeInterface;
 use Irstea\PlantUmlBundle\Writer\WriterInterface;
 
 /**
@@ -16,7 +16,7 @@ use Irstea\PlantUmlBundle\Writer\WriterInterface;
  *
  * @author Guillaume Perréal <guillaume.perreal@irstea.fr>
  */
-class BaseNode implements UmlNodeInterface
+class BaseNode implements NodeInterface
 {
     /**
      * @var string
@@ -123,12 +123,4 @@ class BaseNode implements UmlNodeInterface
     {
         return $this;
     }
-
-    static public function compare(BaseNode $a, BaseNode $b)
-    {
-        if ($a->ordering === $b->ordering) {
-            return strcmp($a->name, $b->name);
-        }
-        return $a->ordering - $b->ordering;
-    }
 }
diff --git a/Model/NodeInterface.php b/Model/NodeInterface.php
new file mode 100644
index 0000000..d4e3522
--- /dev/null
+++ b/Model/NodeInterface.php
@@ -0,0 +1,20 @@
+<?php
+
+/*
+ * © 2016 IRSTEA
+ * Guillaume Perréal <guillaume.perreal@irstea.fr>
+ * Tous droits réservés.
+ */
+
+namespace Irstea\PlantUmlBundle\Model;
+
+use Irstea\PlantUmlBundle\Writer\WritableNodeInterface;
+
+/**
+ *
+ * @author Guillaume Perréal <guillaume.perreal@irstea.fr>
+ */
+interface NodeInterface extends WritableNodeInterface
+{
+    //put your code here
+}
diff --git a/Model/RootNamespace.php b/Model/RootNamespace.php
index 968af9d..efa9f3d 100644
--- a/Model/RootNamespace.php
+++ b/Model/RootNamespace.php
@@ -8,6 +8,8 @@
 
 namespace Irstea\PlantUmlBundle\Model;
 
+use Irstea\PlantUmlBundle\Writer\WriterInterface;
+
 /**
  * Description of RootNamespace
  *
@@ -16,17 +18,17 @@ namespace Irstea\PlantUmlBundle\Model;
 class RootNamespace extends AbstractNamespace
 {
     /**
-     * @var UmlArrowInterface[]
+     * @var ArrowInterface[]
      */
     private $arrows = [];
 
-    public function addArrow(UmlArrowInterface $arrow)
+    public function addArrow(ArrowInterface $arrow)
     {
         $this->arrows[] = $arrow;
         return $this;
     }
 
-    public function outputTo(\Irstea\PlantUmlBundle\Writer\WriterInterface $writer)
+    public function outputTo(WriterInterface $writer)
     {
         $this
             ->outputNodesTo($writer)
@@ -35,7 +37,7 @@ class RootNamespace extends AbstractNamespace
         return $this;
     }
 
-    protected function outputArrowsTo(\Irstea\PlantUmlBundle\Writer\WriterInterface $writer)
+    protected function outputArrowsTo(WriterInterface $writer)
     {
         foreach ($this->arrows as $arrow) {
             $arrow->outputTo($writer);
diff --git a/Model/UmlArrowInterface.php b/Writer/WritableArrowInterface.php
similarity index 65%
rename from Model/UmlArrowInterface.php
rename to Writer/WritableArrowInterface.php
index 9bc1d02..7095832 100644
--- a/Model/UmlArrowInterface.php
+++ b/Writer/WritableArrowInterface.php
@@ -6,12 +6,12 @@
  * Tous droits réservés.
  */
 
-namespace Irstea\PlantUmlBundle\Model;
+namespace Irstea\PlantUmlBundle\Writer;
 
 /**
  *
  * @author Guillaume Perréal <guillaume.perreal@irstea.fr>
  */
-interface UmlArrowInterface extends UmlComponentInterface
+interface WritableArrowInterface extends WritableInterface
 {
 }
diff --git a/Model/UmlComponentInterface.php b/Writer/WritableInterface.php
similarity index 83%
rename from Model/UmlComponentInterface.php
rename to Writer/WritableInterface.php
index 1089443..50fa5aa 100644
--- a/Model/UmlComponentInterface.php
+++ b/Writer/WritableInterface.php
@@ -6,7 +6,7 @@
  * Tous droits réservés.
  */
 
-namespace Irstea\PlantUmlBundle\Model;
+namespace Irstea\PlantUmlBundle\Writer;
 
 use Irstea\PlantUmlBundle\Writer\WriterInterface;
 
@@ -14,7 +14,7 @@ use Irstea\PlantUmlBundle\Writer\WriterInterface;
  *
  * @author Guillaume Perréal <guillaume.perreal@irstea.fr>
  */
-interface UmlComponentInterface
+interface WritableInterface
 {
     /**
      * @param WriterInterface $writer
diff --git a/Model/UmlNodeInterface.php b/Writer/WritableNodeInterface.php
similarity index 78%
rename from Model/UmlNodeInterface.php
rename to Writer/WritableNodeInterface.php
index 8ffed94..cc89d28 100644
--- a/Model/UmlNodeInterface.php
+++ b/Writer/WritableNodeInterface.php
@@ -6,7 +6,7 @@
  * Tous droits réservés.
  */
 
-namespace Irstea\PlantUmlBundle\Model;
+namespace Irstea\PlantUmlBundle\Writer;
 
 use Irstea\PlantUmlBundle\Writer\WriterInterface;
 
@@ -14,7 +14,7 @@ use Irstea\PlantUmlBundle\Writer\WriterInterface;
  *
  * @author Guillaume Perréal <guillaume.perreal@irstea.fr>
  */
-interface UmlNodeInterface extends UmlComponentInterface
+interface WritableNodeInterface extends WritableInterface
 {
     /**
      * @param WriterInterface $writer
-- 
GitLab