Skip to content

Commit

Permalink
Extract Argument processor
Browse files Browse the repository at this point in the history
  • Loading branch information
yvoyer committed Oct 5, 2013
1 parent af19960 commit f0abbab
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 19 deletions.
22 changes: 3 additions & 19 deletions src/Tricorder/Command/TricorderCommand.php
Expand Up @@ -20,10 +20,9 @@
use Symfony\Component\Console\Output\OutputInterface;
use Tricorder\Exception\InvalidArgumentException;
use Tricorder\Formatter\MethodFormatter;
use Tricorder\Processor\ArgumentTypeProcessor;
use Tricorder\Processor\ArgumentProcessor;
use Tricorder\Processor\ReturnTypeProcessor;
use Tricorder\Tag\Extractor\MethodTagExtractor;
use Tricorder\Tag\Extractor\TricorderTagExtractor;

/**
* Class TricorderCommand
Expand Down Expand Up @@ -205,7 +204,8 @@ private function scanMethods(SimpleXMLElement $methods)
}
});

$this->scanArguments((string)$method->name, $paramTags, $tricorderTags);
$argumentProcessor = new ArgumentProcessor($this->output);
$argumentProcessor->process((string)$method->name, $paramTags, $tricorderTags);

// Process ReturnType
$processor = new ReturnTypeProcessor($this->output);
Expand All @@ -215,20 +215,4 @@ private function scanMethods(SimpleXMLElement $methods)
$methodFormatter->outputMessage($this->output);
}
}

/**
* Iterate through our list of arguments for the method, examining the tags
* to see what the types are
*
* @param string $methodName
* @param array $tags
* @param array $tricorderTags
*/
private function scanArguments($methodName, array $tags, array $tricorderTags)
{
$processor = new ArgumentTypeProcessor($this->output);
foreach ($tags as $tag) {
$processor->process($methodName, $tag, $tricorderTags);
}
}
}
48 changes: 48 additions & 0 deletions src/Tricorder/Processor/ArgumentProcessor.php
@@ -0,0 +1,48 @@
<?php
/**
* This file is part of the php-tricorder project.
*
* (c) Yannick Voyer (http://github.com/yvoyer)
*/

namespace Tricorder\Processor;

use Symfony\Component\Console\Output\OutputInterface;

/**
* Class ArgumentProcessor
*
* @author Yannick Voyer (http://github.com/yvoyer)
*
* @package Tricorder\Processor
*/
class ArgumentProcessor implements Processor
{
/**
* @var OutputInterface
*/
private $output;

/**
* @param OutputInterface $output
*/
public function __construct(OutputInterface $output)
{
$this->output = $output;
}

/**
* Look at the $tags and react accordingly
*
* @param string $methodName
* @param array $tag
* @param array $tricorderTags
*/
public function process($methodName, array $tags, array $tricorderTags)
{
$processor = new ArgumentTypeProcessor($this->output);
foreach ($tags as $tag) {
$processor->process($methodName, $tag, $tricorderTags);
}
}
}

0 comments on commit f0abbab

Please sign in to comment.