|
4 | 4 |
|
5 | 5 | class Memcache |
6 | 6 | { |
7 | | - public $brew; |
8 | | - public $cli; |
9 | | - public $pecl; |
| 7 | + /** @var PhpExtension */ |
| 8 | + protected $phpExtension; |
10 | 9 |
|
11 | 10 | /** |
12 | | - * Memcached. |
13 | | - * |
14 | | - * @param Brew $brew |
15 | | - * @param CommandLine $cli |
16 | | - * @param Pecl $pecl |
| 11 | + * @param PhpExtension $phpExtension |
17 | 12 | */ |
18 | | - public function __construct(Brew $brew, CommandLine $cli, Pecl $pecl) |
19 | | - { |
20 | | - $this->cli = $cli; |
21 | | - $this->brew = $brew; |
22 | | - $this->pecl = $pecl; |
| 13 | + public function __construct( |
| 14 | + PhpExtension $phpExtension |
| 15 | + ) { |
| 16 | + $this->phpExtension = $phpExtension; |
23 | 17 | } |
24 | 18 |
|
25 | 19 | /** |
26 | | - * Install service. |
27 | | - * |
| 20 | + * Install memcache. |
| 21 | + * @param $phpVersion |
28 | 22 | * @return bool |
29 | 23 | */ |
30 | | - public function install() |
| 24 | + public function install($phpVersion) |
31 | 25 | { |
32 | | - $restart = false; |
33 | | - if ($this->brew->installed('libmemcached')) { |
34 | | - info('[libmemcached] (brew) already installed'); |
35 | | - } else { |
36 | | - $restart = true; |
37 | | - $this->brew->ensureInstalled('libmemcached'); |
38 | | - info('[libmemcached] Successfully installed'); |
39 | | - } |
40 | | - info('[memcached] Installing'); |
41 | | - $peclInstalled = $this->pecl->installExtension('memcached'); |
42 | | - if ($restart || $peclInstalled) { |
43 | | - return true; |
| 26 | + if (!$this->phpExtension->isInstalled(PhpExtension::MEMCACHE_EXTENSION, $phpVersion)) { |
| 27 | + return $this->phpExtension->installExtension( |
| 28 | + PhpExtension::MEMCACHE_EXTENSION, |
| 29 | + $phpVersion |
| 30 | + ); |
44 | 31 | } |
| 32 | + |
| 33 | + info("[EXTENSION] Memcache extension is already installed!"); |
| 34 | + |
45 | 35 | return false; |
46 | 36 | } |
47 | 37 |
|
48 | 38 | /** |
49 | | - * Uninstall memcached. |
50 | | - * |
| 39 | + * Uninstall memcache. |
| 40 | + * @param $phpVersion |
| 41 | + * @param $phpIniConfigPath |
51 | 42 | * @return bool |
52 | 43 | */ |
53 | | - public function uninstall() |
| 44 | + public function uninstall($phpVersion, $phpIniConfigPath) |
54 | 45 | { |
55 | | - info('[memcached] Uninstalling'); |
56 | | - $removed = $this->pecl->disableExtension('memcached'); |
57 | | - if ($removed) { |
58 | | - info('[memcached] Successfully uninstalled'); |
59 | | - } else { |
60 | | - info('[memcached] was already uninstalled'); |
| 46 | + if ($this->phpExtension->isInstalled(PhpExtension::MEMCACHE_EXTENSION, $phpVersion)) { |
| 47 | + return $this->phpExtension->uninstallExtension( |
| 48 | + PhpExtension::MEMCACHE_EXTENSION, |
| 49 | + $phpVersion, |
| 50 | + $phpIniConfigPath |
| 51 | + ); |
61 | 52 | } |
62 | | - $this->brew->ensureUninstalled('libmemcached'); |
63 | | - info('[libmemcached] Successfully uninstalled'); |
64 | | - return true; |
| 53 | + |
| 54 | + info("[EXTENSION] Memcache extension is already uninstalled!"); |
| 55 | + |
| 56 | + return false; |
65 | 57 | } |
66 | 58 | } |
0 commit comments