diff --git a/Model/AbstractNamespace.php b/Model/AbstractNamespace.php index 783846d83d343b70bf450c01b72a26d0c29a89a9..5cc0538ed707f8082ff3136b6589cf6917f40391 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 5ba6bc8ac7976ff5a28188e5ff3b10756e8ce33b..f281c23ecf892694622156388010929033c725fe 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 9a0c0d6c2e9a5ebe12157ce7e0242547225877c7..28aa52b39553bad8fac9bf6138a124ff78b6ee40 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 bd7451b50fc3c1796820e7b9471e1e9d20f93c47..ad515627c690fbfa0347ed56389c9f419baac571 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 9d59279264db355f1214500dc3f2010b2e61e3c1..ce564c00bf06bb2bcfdac47f03ed24641575bfc6 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 0000000000000000000000000000000000000000..8180084cbd69ea001bc19037d93b11dcf4ab41a1 --- /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 08553b628184db102213880602a5ecf04120081a..f3017f588de2b748adad95f2b4bc3bbdc4704d0c 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 6afc61e98b5513d2d835fabe2e3feb416f78af5c..91071200e816a922dbab8f2c86aaa80741ec01ca 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 1a1e01a96172eecc0d616aeda7d5e16971f690ff..b2639d1e0c3e0eb93ef7a4d4ac4839a693d7aa7b 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 09d4f326ec8d5467a203ae612aea2dcc55ec1046..0b504cafe34cd91046b7e73d0cd20c6dfc21c563 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 5c766dc54baf7848170b43c17d9fdbcb24f6ee7a..aa60ea45d935975159c53a22c279a1902fb79eb7 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 0000000000000000000000000000000000000000..d4e3522be563408f4231b8c8d501d29bfb4a8e92 --- /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 968af9d5a70190aea6a18016841e3950f17617b9..efa9f3df785d9d7cf02bc405f12e557543c5d565 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 9bc1d028c59a7f33f6931b95d13ae12123552150..70958320b79be06f9f58976ff7943775e68d3e05 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 1089443982dde26122946cccb16788823e326eb9..50fa5aacddc2fdab276e20601a36241d3c374077 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 8ffed94865aa08de34c27ebe517b703d9e518fa7..cc89d2803e92b1cd761adfe963d45616382931e4 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