Skip to content

Commit

Permalink
- Refactor to increase code reuse.
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastianbergmann committed Sep 1, 2009
1 parent c905baa commit c0477f8
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 46 deletions.
Binary file modified design/class_diagram.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
14 changes: 12 additions & 2 deletions src/interfaces/visitor.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
*/

/**
* Abstract base class for visitor implementations that want to process
* Base class for visitor implementations that want to process
* a workflow using the Visitor design pattern.
*
* visit() is called on each of the nodes in the workflow in a top-down,
Expand All @@ -21,7 +21,7 @@
* @package Workflow
* @version //autogen//
*/
abstract class ezcWorkflowVisitor
class ezcWorkflowVisitor implements Countable
{
/**
* Holds the visited nodes.
Expand All @@ -38,6 +38,16 @@ public function __construct()
$this->visited = new SplObjectStorage;
}

/**
* Returns the number of visited nodes.
*
* @return integer
*/
public function count()
{
return count( $this->visited );
}

/**
* Visit the $visitable.
*
Expand Down
41 changes: 0 additions & 41 deletions src/visitors/node_counter.php

This file was deleted.

5 changes: 3 additions & 2 deletions src/workflow.php
Original file line number Diff line number Diff line change
Expand Up @@ -253,9 +253,10 @@ public function __isset( $propertyName )
*/
public function count()
{
$counter = new ezcWorkflowVisitorNodeCounter( $this );
$visitor = new ezcWorkflowVisitor;
$this->accept( $visitor );

return $counter->getNumNodes();
return count( $visitor );
}

/**
Expand Down
1 change: 0 additions & 1 deletion src/workflow_autoload.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@
'ezcWorkflowUtil' => 'Workflow/util.php',
'ezcWorkflowVariableHandler' => 'Workflow/interfaces/variable_handler.php',
'ezcWorkflowVisitorNodeCollector' => 'Workflow/visitors/node_collector.php',
'ezcWorkflowVisitorNodeCounter' => 'Workflow/visitors/node_counter.php',
'ezcWorkflowVisitorReset' => 'Workflow/visitors/reset.php',
'ezcWorkflowVisitorVerification' => 'Workflow/visitors/verification.php',
'ezcWorkflowVisitorVisualization' => 'Workflow/visitors/visualization.php',
Expand Down

0 comments on commit c0477f8

Please sign in to comment.