Total Complexity | 7 |
Total Lines | 65 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | <?php |
||
11 | class TraitCreator implements Writeable |
||
12 | { |
||
13 | private $handle; |
||
14 | |||
15 | private $creators; |
||
16 | |||
17 | public function __construct(string $file) |
||
18 | { |
||
19 | $this->handle = fopen($file, 'w'); |
||
20 | $this->creators = []; |
||
21 | } |
||
22 | public function create() : void |
||
44 | } |
||
45 | |||
46 | public function addCreator(Createable $creator) : void |
||
47 | { |
||
48 | $this->creators[$creator->getClass()] = $creator; |
||
49 | } |
||
50 | |||
51 | public function write(string $string) : void |
||
52 | { |
||
53 | $string = preg_replace( |
||
54 | [ |
||
55 | '/[ \t]+%%/', |
||
56 | '/[ \t]+%indent%/', |
||
57 | ], |
||
58 | [ |
||
59 | '', |
||
60 | ' ', |
||
61 | ], |
||
62 | $string |
||
63 | ); |
||
64 | |||
65 | fwrite($this->handle, $string); |
||
|
|||
66 | } |
||
67 | |||
68 | public function __destruct() |
||
71 | } |
||
72 | |||
73 | public function addAlias(string $alias, string $class) : void |
||
76 | } |
||
77 | } |
||
78 |