| Code Coverage
| Classes and Traits | Functions and Methods | Lines
Total | 0.00% covered (danger) | 0.00% | 0 / 1 | 66.67% covered (warning) | 66.67% | 2 / 3 | CRAP | 81.82% covered (warning) | 81.82% | 9 / 11
StringManipulationGenerator | 0.00% covered (danger) | 0.00% | 0 / 1 | 66.67% covered (warning) | 66.67% | 2 / 3 | 5.15 | 81.82% covered (warning) | 81.82% | 9 / 11
__construct(array $passes) | 100.00% covered (success) | 100.00% | 1 / 1 | 1 | 100.00% covered (success) | 100.00% | 2 / 2
generate(MockConfiguration $config) | 100.00% covered (success) | 100.00% | 1 / 1 | 3 | 100.00% covered (success) | 100.00% | 7 / 7
addPass(Pass $pass) | 0.00% covered (danger) | 0.00% | 0 / 1 | 2 | 0.00% covered (danger) | 0.00% | 0 / 2

1 | <?php
2 |
3 | namespace Mockery\Generator;
4 |
5 | use Mockery\Generator\StringManipulation\Pass\Pass;
6 |
7 | class StringManipulationGenerator implements Generator
8 | {
9 | protected $passes = array();
10 |
11 | public function __construct(array $passes)
12 | {
13 | $this->passes = $passes;
14 | }
15 |
16 | public function generate(MockConfiguration $config)
17 | {
18 | $code = file_get_contents(__DIR__ . '/../Mock.php');
19 | $className = $config->getName() ?: $config->generateName();
20 |
21 | $namedConfig = $config->rename($className);
22 |
23 | foreach ($this->passes as $pass) {
24 | $code = $pass->apply($code, $namedConfig);
25 | }
26 |
27 | return new MockDefinition($namedConfig, $code);
28 | }
29 |
30 | public function addPass(Pass $pass)
31 | {
32 | $this->passes[] = $pass;
33 | }
34 | }