1 | <?php |
||
25 | class Installer extends HookHandler |
||
26 | { |
||
27 | /** |
||
28 | * Overwrite hook |
||
29 | * |
||
30 | * @var bool |
||
31 | */ |
||
32 | private $force; |
||
33 | |||
34 | /** |
||
35 | * @param bool $force |
||
36 | * @return \SebastianFeldmann\CaptainHook\Runner\Installer |
||
37 | */ |
||
38 | 2 | public function setForce(bool $force) |
|
43 | |||
44 | /** |
||
45 | * Execute installation. |
||
46 | */ |
||
47 | 2 | public function run() |
|
55 | |||
56 | /** |
||
57 | * Return list of hooks to install. |
||
58 | * |
||
59 | * @return array |
||
60 | */ |
||
61 | 2 | public function getHooksToInstall() : array |
|
65 | |||
66 | /** |
||
67 | * Install given hook. |
||
68 | * |
||
69 | * @param string $hook |
||
70 | * @param bool $ask |
||
71 | */ |
||
72 | 3 | public function installHook(string $hook, bool $ask) |
|
84 | |||
85 | /** |
||
86 | * Write given hook to .git/hooks directory |
||
87 | * |
||
88 | * @param string $hook |
||
89 | */ |
||
90 | 3 | public function writeHookFile(string $hook) |
|
111 | |||
112 | /** |
||
113 | * Return the source code for a given hook script. |
||
114 | * |
||
115 | * @param string $hook |
||
116 | * @return string |
||
117 | */ |
||
118 | 2 | protected function getHookSourceCode(string $hook) : string |
|
125 | |||
126 | /** |
||
127 | * If the hook already exists the user has to confirm the installation. |
||
128 | * |
||
129 | * @param string $hook The name of the hook to check |
||
130 | * @return bool |
||
131 | */ |
||
132 | 3 | protected function needInstallConfirmation(string $hook) : bool |
|
136 | } |
||
137 |