1 | <?php |
||
20 | class Mysqlimport extends Abstraction implements Executable |
||
21 | { |
||
22 | use OptionMasker; |
||
23 | |||
24 | /** |
||
25 | * Host to connect to |
||
26 | * --host <hostname> |
||
27 | * |
||
28 | * @var string |
||
29 | */ |
||
30 | private $host; |
||
31 | |||
32 | /** |
||
33 | * Port to connect to |
||
34 | * --port <number> |
||
35 | * |
||
36 | * @var int |
||
37 | */ |
||
38 | private $port; |
||
39 | |||
40 | /** |
||
41 | * The connection protocol |
||
42 | * --protocol |
||
43 | * |
||
44 | * @var string |
||
45 | */ |
||
46 | private $protocol; |
||
47 | |||
48 | /** |
||
49 | * User to connect with |
||
50 | * --user <username> |
||
51 | * |
||
52 | * @var string |
||
53 | */ |
||
54 | private $user; |
||
55 | |||
56 | /** |
||
57 | * Password to authenticate with |
||
58 | * --password <password> |
||
59 | * |
||
60 | * @var string |
||
61 | */ |
||
62 | private $password; |
||
63 | |||
64 | /** |
||
65 | * Target database |
||
66 | * |
||
67 | * @var string |
||
68 | */ |
||
69 | private $database; |
||
70 | |||
71 | /** |
||
72 | * Name of the source file. |
||
73 | * |
||
74 | * @var string |
||
75 | */ |
||
76 | private $sourceFilename; |
||
77 | |||
78 | /** |
||
79 | * Use mysqlimport with compression |
||
80 | * -C |
||
81 | * |
||
82 | * @var bool |
||
83 | */ |
||
84 | private $compress = false; |
||
85 | |||
86 | /** |
||
87 | * Constructor. |
||
88 | * |
||
89 | * @param string $path |
||
90 | */ |
||
91 | 9 | public function __construct(string $path = '') |
|
96 | |||
97 | /** |
||
98 | * Set the source filename and the target database. |
||
99 | * |
||
100 | * @param string $sourceFilename |
||
101 | * @param string $targetDatabase |
||
102 | * @return \phpbu\App\Cli\Executable\Mysqlimport |
||
103 | */ |
||
104 | 8 | public function setSourceAndTarget(string $sourceFilename, string $targetDatabase) : Mysqlimport |
|
110 | |||
111 | /** |
||
112 | * Set the credentials. |
||
113 | * |
||
114 | * @param string $user |
||
115 | * @param string $password |
||
116 | * @return \phpbu\App\Cli\Executable\Mysqlimport |
||
117 | */ |
||
118 | 3 | public function credentials(string $user = '', string $password = '') : Mysqlimport |
|
124 | |||
125 | /** |
||
126 | * Set the hostname. |
||
127 | * |
||
128 | * @param string $host |
||
129 | * @return \phpbu\App\Cli\Executable\Mysqlimport |
||
130 | */ |
||
131 | 2 | public function useHost(string $host) : Mysqlimport |
|
136 | |||
137 | /** |
||
138 | * Set the port. |
||
139 | * |
||
140 | * @param int $port |
||
141 | * @return \phpbu\App\Cli\Executable\Mysqlimport |
||
142 | */ |
||
143 | 2 | public function usePort(int $port) : Mysqlimport |
|
148 | |||
149 | /** |
||
150 | * Set the connection protocol. |
||
151 | * |
||
152 | * @param string $protocol |
||
153 | * @return \phpbu\App\Cli\Executable\Mysqlimport |
||
154 | */ |
||
155 | 2 | public function useProtocol(string $protocol) : Mysqlimport |
|
160 | |||
161 | /** |
||
162 | * Use '-C' compress mode. |
||
163 | * |
||
164 | * @param bool $bool |
||
165 | * @return \phpbu\App\Cli\Executable\Mysqlimport |
||
166 | */ |
||
167 | 1 | public function useCompression(bool $bool) : Mysqlimport |
|
172 | |||
173 | /** |
||
174 | * Mysqlimport CommandLine generator. |
||
175 | * |
||
176 | * @return \SebastianFeldmann\Cli\CommandLine |
||
177 | * @throws \phpbu\App\Exception |
||
178 | */ |
||
179 | 9 | protected function createCommandLine(): CommandLine |
|
204 | } |
||
205 |