1 | <?php |
||
19 | class Mysql extends Abstraction implements Executable |
||
20 | { |
||
21 | use OptionMasker; |
||
22 | |||
23 | /** |
||
24 | * Host to connect to |
||
25 | * --host <hostname> |
||
26 | * |
||
27 | * @var string |
||
28 | */ |
||
29 | private $host; |
||
30 | |||
31 | /** |
||
32 | * Port to connect to |
||
33 | * --port <number> |
||
34 | * |
||
35 | * @var int |
||
36 | */ |
||
37 | private $port; |
||
38 | |||
39 | /** |
||
40 | * The connection protocol |
||
41 | * --protocol |
||
42 | * |
||
43 | * @var string |
||
44 | */ |
||
45 | private $protocol; |
||
46 | |||
47 | /** |
||
48 | * User to connect with |
||
49 | * --user <username> |
||
50 | * |
||
51 | * @var string |
||
52 | */ |
||
53 | private $user; |
||
54 | |||
55 | /** |
||
56 | * Password to authenticate with |
||
57 | * --password <password> |
||
58 | * |
||
59 | * @var string |
||
60 | */ |
||
61 | private $password; |
||
62 | |||
63 | /** |
||
64 | * Database to connect to |
||
65 | * --database <database> |
||
66 | * |
||
67 | * @var string |
||
68 | */ |
||
69 | private $database; |
||
70 | |||
71 | /** |
||
72 | * Use mysql quick mode |
||
73 | * -q |
||
74 | * |
||
75 | * @var bool |
||
76 | */ |
||
77 | private $quick = false; |
||
78 | |||
79 | /** |
||
80 | * Use mysql with compression |
||
81 | * -C |
||
82 | * |
||
83 | * @var bool |
||
84 | */ |
||
85 | private $compress = false; |
||
86 | |||
87 | /** |
||
88 | * Name of the source file. |
||
89 | * -e "source $file" |
||
90 | * |
||
91 | * @var string |
||
92 | */ |
||
93 | private $sourceFilename; |
||
94 | |||
95 | /** |
||
96 | * Constructor. |
||
97 | * |
||
98 | * @param string $path |
||
99 | */ |
||
100 | 11 | public function __construct(string $path = '') |
|
105 | |||
106 | /** |
||
107 | * Set the credentials. |
||
108 | * |
||
109 | * @param string $user |
||
110 | * @param string $password |
||
111 | * @return \phpbu\App\Cli\Executable\Mysql |
||
112 | */ |
||
113 | 4 | public function credentials(string $user = '', string $password = '') : Mysql |
|
119 | |||
120 | /** |
||
121 | * Set the hostname. |
||
122 | * |
||
123 | * @param string $host |
||
124 | * @return \phpbu\App\Cli\Executable\Mysql |
||
125 | */ |
||
126 | 3 | public function useHost(string $host) : Mysql |
|
131 | |||
132 | /** |
||
133 | * Set the port. |
||
134 | * |
||
135 | * @param int $port |
||
136 | * @return \phpbu\App\Cli\Executable\Mysql |
||
137 | */ |
||
138 | 3 | public function usePort(int $port) : Mysql |
|
143 | |||
144 | /** |
||
145 | * Set the connection protocol. |
||
146 | * |
||
147 | * @param string $protocol |
||
148 | * @return \phpbu\App\Cli\Executable\Mysql |
||
149 | */ |
||
150 | 3 | public function useProtocol(string $protocol) : Mysql |
|
155 | |||
156 | /** |
||
157 | * Set the database. |
||
158 | * |
||
159 | * @param string $database |
||
160 | * @return \phpbu\App\Cli\Executable\Mysql |
||
161 | */ |
||
162 | 2 | public function useDatabase(string $database) : Mysql |
|
167 | |||
168 | /** |
||
169 | * Use '-q' quick mode. |
||
170 | * |
||
171 | * @param boolean $bool |
||
172 | * @return \phpbu\App\Cli\Executable\Mysql |
||
173 | */ |
||
174 | 2 | public function useQuickMode(bool $bool) : Mysql |
|
179 | |||
180 | /** |
||
181 | * Use '-C' compress mode. |
||
182 | * |
||
183 | * @param bool $bool |
||
184 | * @return \phpbu\App\Cli\Executable\Mysql |
||
185 | */ |
||
186 | 2 | public function useCompression(bool $bool) : Mysql |
|
191 | |||
192 | /** |
||
193 | * Set the source filename. |
||
194 | * |
||
195 | * @param string $sourceFilename |
||
196 | * |
||
197 | * @return \phpbu\App\Cli\Executable\Mysql |
||
198 | */ |
||
199 | 3 | public function useSourceFile(string $sourceFilename) : Mysql |
|
204 | |||
205 | /** |
||
206 | * Mysql CommandLine generator. |
||
207 | * |
||
208 | * @return \SebastianFeldmann\Cli\CommandLine |
||
209 | * @throws \phpbu\App\Exception |
||
210 | */ |
||
211 | 11 | protected function createCommandLine() : CommandLine |
|
232 | } |
||
233 |