Code Coverage |
||||||||||
Classes and Traits |
Functions and Methods |
Lines |
||||||||
Total | |
100.00% |
1 / 1 |
|
100.00% |
3 / 3 |
CRAP | |
100.00% |
6 / 6 |
Refactored | |
100.00% |
1 / 1 |
|
100.00% |
3 / 3 |
4 | |
100.00% |
6 / 6 |
pushNewContract($fqcn, $interfaceName) | |
100.00% |
1 / 1 |
2 | |
100.00% |
4 / 4 |
|||
hasNewContract($fqcn) | |
100.00% |
1 / 1 |
1 | |
100.00% |
1 / 1 |
|||
getNewContract($fqcn) | |
100.00% |
1 / 1 |
1 | |
100.00% |
1 / 1 |
<?php | |
/* | |
* Mondrian | |
*/ | |
namespace Trismegiste\Mondrian\Refactor; | |
/** | |
* Refactored is a container for refactoring changes | |
*/ | |
class Refactored | |
{ | |
protected $newContract = array(); | |
/** | |
* Stack a new contract for a concrete class | |
* | |
* @param string $fqcn FQCN | |
* @param string $interfaceName name of interface (fully qualified) | |
*/ | |
public function pushNewContract($fqcn, $interfaceName) | |
{ | |
if (in_array($interfaceName, $this->newContract)) { | |
throw new \LogicException("Two classes want to create the same contract"); | |
} | |
$this->newContract[$fqcn] = $interfaceName; | |
} | |
/** | |
* Is there a new contract for a concrete class ? | |
* | |
* @param string $fqcn FQCN | |
*/ | |
public function hasNewContract($fqcn) | |
{ | |
return array_key_exists($fqcn, $this->newContract); | |
} | |
/** | |
* Get the new contract for a concrete class | |
* | |
* @param string $fqcn FQCN | |
*/ | |
public function getNewContract($fqcn) | |
{ | |
return $this->newContract[$fqcn]; | |
} | |
} |