| Conditions | 6 |
| Paths | 2 |
| Total Lines | 30 |
| Code Lines | 16 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 2 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php declare(strict_types=1); |
||
| 20 | public function build(string|false $file = null): bool|string |
||
| 21 | { |
||
| 22 | $prepared = preg_replace_callback('/%.*%/U', function ($m) { |
||
| 23 | if ($m[0] === '%phpdoc%') { |
||
| 24 | $string = '/**'; |
||
| 25 | |||
| 26 | foreach ($this->components as $name => $classes) { |
||
| 27 | $string .= PHP_EOL . ' * @property ' . implode('|', $classes) . ' $' . $name; |
||
| 28 | } |
||
| 29 | $string .= PHP_EOL . ' */'; |
||
| 30 | |||
| 31 | return $string; |
||
| 32 | } |
||
| 33 | |||
| 34 | if ($m[0] === '%webapp%') { |
||
| 35 | return $this->webAppClass ?? '\yii\web\Application'; |
||
| 36 | } |
||
| 37 | |||
| 38 | if ($m[0] === '%consoleapp%') { |
||
| 39 | return $this->consoleAppClass ?? '\yii\console\Application'; |
||
| 40 | } |
||
| 41 | |||
| 42 | return $m[0]; |
||
| 43 | }, $this->template); |
||
| 44 | |||
| 45 | if ($file === null) { |
||
| 46 | return $prepared; |
||
| 47 | } |
||
| 48 | |||
| 49 | return (bool)file_put_contents($file, $prepared); |
||
|
|
|||
| 50 | } |
||
| 52 |