| Total Complexity | 10 |
| Total Lines | 92 |
| Duplicated Lines | 0 % |
| Changes | 5 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 24 | abstract class Generator implements GeneratorInterface |
||
| 25 | { |
||
| 26 | // Public Static Methods |
||
| 27 | // ========================================================================= |
||
| 28 | |||
| 29 | /** |
||
| 30 | * @inheritDoc |
||
| 31 | */ |
||
| 32 | public static function getGeneratorName(): string |
||
| 35 | } |
||
| 36 | |||
| 37 | /** |
||
| 38 | * @inheritDoc |
||
| 39 | */ |
||
| 40 | public static function getGeneratorStubsPath(): string |
||
| 41 | { |
||
| 42 | return Autocomplete::getInstance()->basePath . self::STUBS_DIR; |
||
| 43 | } |
||
| 44 | |||
| 45 | /** |
||
| 46 | * @inheritDoc |
||
| 47 | */ |
||
| 48 | public static function generate() |
||
| 49 | { |
||
| 50 | } |
||
| 51 | |||
| 52 | /** |
||
| 53 | * @inheritDoc |
||
| 54 | */ |
||
| 55 | public static function regenerate() |
||
| 57 | } |
||
| 58 | |||
| 59 | /** |
||
| 60 | * @inheritDoc |
||
| 61 | */ |
||
| 62 | public static function delete() |
||
| 63 | { |
||
| 64 | unlink(static::getGeneratedFilePath()); |
||
| 65 | } |
||
| 66 | |||
| 67 | // Protected Static Methods |
||
| 68 | // ========================================================================= |
||
| 69 | |||
| 70 | /** |
||
| 71 | * Save the template to disk, with variable substitution |
||
| 72 | * |
||
| 73 | * @param array $vars key/value variables to be replaced in the stub |
||
| 74 | * @return bool Whether the template was successfully saved |
||
| 75 | */ |
||
| 76 | protected static function saveTemplate(array $vars): bool |
||
| 86 | } |
||
| 87 | |||
| 88 | /** |
||
| 89 | * Don't regenerate the file if it already exists |
||
| 90 | * |
||
| 91 | * @return bool |
||
| 92 | */ |
||
| 93 | protected static function shouldRegenerateFile(): bool |
||
| 94 | { |
||
| 95 | return !is_file(static::getGeneratedFilePath()); |
||
| 96 | } |
||
| 97 | |||
| 98 | /** |
||
| 99 | * Return a path to the generated autocomplete template file |
||
| 100 | * |
||
| 101 | * @return string |
||
| 102 | */ |
||
| 103 | protected static function getGeneratedFilePath(): string |
||
| 106 | } |
||
| 107 | |||
| 108 | /** |
||
| 109 | * Return a path to the autocomplete template stub |
||
| 110 | * |
||
| 111 | * @return string |
||
| 112 | */ |
||
| 113 | protected static function getStubFilePath(): string |
||
| 116 | } |
||
| 117 | } |
||
| 118 |