Commit b8bcadb6 authored by Guillaume Perréal's avatar Guillaume Perréal
Browse files

Refactoring: Uml*Interface => Writable*Interface.

parent 85f81393
......@@ -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;
......
......@@ -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;
......
......@@ -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, "<|--");
}
......
......@@ -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, "<|..");
}
......
......@@ -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, "<|--");
}
......
<?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
}
......@@ -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);
......
......@@ -15,7 +15,7 @@ namespace Irstea\PlantUmlBundle\Model;
interface ClassVisitorInterface
{
/**
* @return UmlNodeInterface
* @return NodeInterface
*/
public function visitClass($className);
}
......@@ -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);
}
......@@ -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;
......
......@@ -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;
}
}
<?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
}
......@@ -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);
......
......@@ -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
{
}
......@@ -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
......
......@@ -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
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment