Code Coverage |
||||||||||
Classes and Traits |
Functions and Methods |
Lines |
||||||||
| Total | |
0.00% |
0 / 1 |
|
50.00% |
1 / 2 |
CRAP | |
87.50% |
7 / 8 |
| CachingGenerator | |
0.00% |
0 / 1 |
|
50.00% |
1 / 2 |
3.02 | |
87.50% |
7 / 8 |
| __construct(Generator $generator) | |
100.00% |
1 / 1 |
1 | |
100.00% |
2 / 2 |
|||
| generate(MockConfiguration $config) | |
0.00% |
0 / 1 |
2.02 | |
83.33% |
5 / 6 |
|||
| <?php | |
| namespace Mockery\Generator; | |
| class CachingGenerator implements Generator | |
| { | |
| protected $generator; | |
| protected $cache = array(); | |
| public function __construct(Generator $generator) | |
| { | |
| $this->generator = $generator; | |
| } | |
| public function generate(MockConfiguration $config) | |
| { | |
| $hash = $config->getHash(); | |
| if (isset($this->cache[$hash])) { | |
| return $this->cache[$hash]; | |
| } | |
| $definition = $this->generator->generate($config); | |
| $this->cache[$hash] = $definition; | |
| return $definition; | |
| } | |
| } |