1 <?php
2
3 namespace Scaffolder\Compilers;
4
5 use Scaffolder\Support\FileToCompile;
6 use stdClass;
7
8 abstract class AbstractCompiler
9 {
10 11 12 13
14 protected $stub;
15
16
17 18 19
20 const CACHE_EXT = '.scf';
21
22 23 24 25 26 27 28 29 30 31
32 abstract protected function store($modelName, stdClass $scaffolderConfig, $compiled, FileToCompile $fileToCompile);
33
34 35 36 37 38 39 40
41 protected function replaceClassName($modelName)
42 {
43 $this->stub = str_replace('{{class_name}}', $modelName, $this->stub);
44 $this->stub = str_replace('{{class_name_lw}}', strtolower($modelName), $this->stub);
45
46 return $this;
47 }
48
49 50 51 52 53 54 55
56 protected function replaceNamespace(stdClass $scaffolderConfig)
57 {
58 $this->stub = str_replace('{{namespace}}', $scaffolderConfig->namespaces->models, $this->stub);
59
60 return $this;
61 }
62
63 64 65 66 67 68 69
70 protected function tab($size)
71 {
72 return str_repeat(' ', $size);
73 }
74 }
75