Code Coverage |
||||||||||
Classes and Traits |
Functions and Methods |
Lines |
||||||||
| Total | |
100.00% |
1 / 1 |
|
100.00% |
5 / 5 |
CRAP | |
100.00% |
13 / 13 |
| NewContractCollector | |
100.00% |
1 / 1 |
|
100.00% |
5 / 5 |
6 | |
100.00% |
13 / 13 |
| __construct(Refactored $ctx) | |
100.00% |
1 / 1 |
1 | |
100.00% |
2 / 2 |
|||
| enterClassNode(\PHPParser_Node_Stmt_Class $node) | |
100.00% |
1 / 1 |
2 | |
100.00% |
8 / 8 |
|||
| enterInterfaceNode(\PHPParser_Node_Stmt_Interface $node) | |
100.00% |
1 / 1 |
1 | |
100.00% |
1 / 1 |
|||
| enterPublicMethodNode(\PHPParser_Node_Stmt_ClassMethod $node) | |
100.00% |
1 / 1 |
1 | |
100.00% |
1 / 1 |
|||
| enterTraitNode(\PHPParser_Node_Stmt_Trait $node) | |
100.00% |
1 / 1 |
1 | |
100.00% |
1 / 1 |
|||
| <?php | |
| /* | |
| * Mondrian | |
| */ | |
| namespace Trismegiste\Mondrian\Visitor; | |
| use Trismegiste\Mondrian\Refactor\Refactored; | |
| /** | |
| * NewContractCollector gather classe which needs to be refactor with a contract. | |
| * | |
| * Adds the new interface so changes could be made to the current PhpFile | |
| */ | |
| class NewContractCollector extends PublicCollector | |
| { | |
| protected $context; | |
| public function __construct(Refactored $ctx) | |
| { | |
| $this->context = $ctx; | |
| } | |
| /** | |
| * {@inheritDoc} | |
| */ | |
| protected function enterClassNode(\PHPParser_Node_Stmt_Class $node) | |
| { | |
| $this->extractAnnotation($node); | |
| if ($node->hasAttribute('contractor')) { | |
| $interfaceName = new \PHPParser_Node_Name(reset($node->getAttribute('contractor'))); | |
| $this->context->pushNewContract($this->getNamespacedName($node), (string) $this->resolveClassName($interfaceName)); | |
| $node->implements[] = $interfaceName; | |
| $this->currentPhpFile->modified(); | |
| } | |
| } | |
| /** | |
| * do nothing | |
| */ | |
| protected function enterInterfaceNode(\PHPParser_Node_Stmt_Interface $node) | |
| { | |
| } | |
| /** | |
| * do nothing | |
| */ | |
| protected function enterPublicMethodNode(\PHPParser_Node_Stmt_ClassMethod $node) | |
| { | |
| } | |
| /** | |
| * do nothing | |
| */ | |
| protected function enterTraitNode(\PHPParser_Node_Stmt_Trait $node) | |
| { | |
| } | |
| } |