Skip to content

Commit

Permalink
Move from Converter to Exporter wording. Sorry for the BC.
Browse files Browse the repository at this point in the history
  • Loading branch information
drupol committed Dec 16, 2018
1 parent 67d2320 commit 1b1b02e
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

declare(strict_types = 1);

namespace spec\drupol\phptree\Converter;
namespace spec\drupol\phptree\Exporter;

use drupol\phptree\Converter\Graph;
use drupol\phptree\Exporter\Graph;
use drupol\phptree\Node\Node;
use drupol\phptree\Node\ValueNode;
use drupol\phptree\Traverser\BreadthFirst;
Expand All @@ -27,7 +27,7 @@ public function it_can_generate_a_graph()
->add($child1, $child2, $child3);

$this
->convert($root)
->export($root)
->shouldReturnAnInstanceOf(\Fhaculty\Graph\Graph::class);

$this
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

declare(strict_types = 1);

namespace spec\drupol\phptree\tests\Converter;
namespace spec\drupol\phptree\tests\Exporter;

use drupol\phptree\Node\ValueNode;
use drupol\phptree\tests\Converter\ValueGraph;
use drupol\phptree\tests\Exporter\ValueGraph;
use PhpSpec\ObjectBehavior;

class ValueGraphSpec extends ObjectBehavior
Expand All @@ -20,7 +20,7 @@ public function it_can_be_extended()
$tree = new ValueNode('root');

$this
->convert($tree)
->export($tree)
->shouldReturnAnInstanceOf(\Fhaculty\Graph\Graph::class);
}
}
20 changes: 0 additions & 20 deletions src/Converter/ConverterInterface.php

This file was deleted.

24 changes: 24 additions & 0 deletions src/Exporter/ExporterInterface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?php

declare(strict_types = 1);

namespace drupol\phptree\Exporter;

use drupol\phptree\Node\ValueNodeInterface;

/**
* Interface ExporterInterface
*/
interface ExporterInterface
{
/**
* Export a node into something.
*
* @param \drupol\phptree\Node\ValueNodeInterface $node
* The node.
*
* @return mixed
* The node exported.
*/
public function export(ValueNodeInterface $node);
}
13 changes: 9 additions & 4 deletions src/Converter/Graph.php → src/Exporter/Graph.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@

declare(strict_types = 1);

namespace drupol\phptree\Converter;
namespace drupol\phptree\Exporter;

use drupol\phptree\Node\NodeInterface;
use drupol\phptree\Node\ValueNodeInterface;
use drupol\phptree\Traverser\BreadthFirst;
use drupol\phptree\Traverser\TraverserInterface;
use Fhaculty\Graph\Graph as OriginalGraph;
Expand All @@ -13,7 +14,7 @@
/**
* Class Graph
*/
class Graph implements ConverterInterface
class Graph implements ExporterInterface
{
/**
* @var \Fhaculty\Graph\Graph
Expand Down Expand Up @@ -54,11 +55,15 @@ public function getTraverser(): TraverserInterface
}

/**
* @param \drupol\phptree\Node\NodeInterface $node
* Export a node into a Graph.
*
* @param \drupol\phptree\Node\ValueNodeInterface $node
* The node.
*
* @return \Fhaculty\Graph\Graph
* The graph.
*/
public function convert(NodeInterface $node): OriginalGraph
public function export(ValueNodeInterface $node): OriginalGraph
{
foreach ($this->getTraverser()->traverse($node) as $node_visited) {
/** @var int $vertexId */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

declare(strict_types = 1);

namespace drupol\phptree\tests\Converter;
namespace drupol\phptree\tests\Exporter;

use drupol\phptree\Converter\Graph;
use drupol\phptree\Exporter\Graph;
use drupol\phptree\Node\NodeInterface;
use Fhaculty\Graph\Vertex;

Expand Down

0 comments on commit 1b1b02e

Please sign in to comment.