@@ -41,13 +41,19 @@ public function __construct(public array $options = [])
4141 {
4242 }
4343
44+ /**
45+ * Set SQL Loader options.
46+ */
4447 public function options (array $ options ): static
4548 {
4649 $ this ->options = $ options ;
4750
4851 return $ this ;
4952 }
5053
54+ /**
55+ * Define input file to load data from.
56+ */
5157 public function inFile (
5258 string $ path ,
5359 ?string $ badFile = null ,
@@ -63,13 +69,19 @@ public function inFile(
6369 return $ this ;
6470 }
6571
72+ /**
73+ * Define mode to use.
74+ */
6675 public function mode (Mode $ mode ): static
6776 {
6877 $ this ->mode = $ mode ;
6978
7079 return $ this ;
7180 }
7281
82+ /**
83+ * Define table to load data into.
84+ */
7385 public function into (
7486 string $ table ,
7587 array $ columns ,
@@ -83,6 +95,9 @@ public function into(
8395 return $ this ;
8496 }
8597
98+ /**
99+ * Execute SQL Loader command.
100+ */
86101 public function execute (): ProcessResult
87102 {
88103 if (! $ this ->tables ) {
@@ -106,6 +121,9 @@ public function execute(): ProcessResult
106121 return $ this ->result ; // @phpstan-ignore-line
107122 }
108123
124+ /**
125+ * Build SQL Loader command.
126+ */
109127 protected function buildCommand (): string
110128 {
111129 $ filesystem = $ this ->getDisk ();
@@ -125,6 +143,9 @@ protected function buildCommand(): string
125143 return $ command ;
126144 }
127145
146+ /**
147+ * Get the disk to use for control file.
148+ */
128149 public function getDisk (): Filesystem
129150 {
130151 if ($ this ->disk ) {
@@ -134,13 +155,19 @@ public function getDisk(): Filesystem
134155 return Storage::disk (config ('sql-loader.disk ' , 'local ' ));
135156 }
136157
158+ /**
159+ * Set the disk to use for control file.
160+ */
137161 public function disk (string $ disk ): static
138162 {
139163 $ this ->disk = $ disk ;
140164
141165 return $ this ;
142166 }
143167
168+ /**
169+ * Get the control file name.
170+ */
144171 protected function getControlFile (): string
145172 {
146173 if (! $ this ->controlFile ) {
@@ -150,26 +177,41 @@ protected function getControlFile(): string
150177 return $ this ->controlFile ;
151178 }
152179
180+ /**
181+ * Build SQL Loader control file.
182+ */
153183 public function buildControlFile (): string
154184 {
155185 return (new ControlFileBuilder ($ this ))->build ();
156186 }
157187
188+ /**
189+ * Build TNS connection string.
190+ */
158191 protected function buildTNS (): string
159192 {
160193 return TnsBuilder::make ();
161194 }
162195
196+ /**
197+ * Create a new SQL Loader instance.
198+ */
163199 public static function make (array $ options = []): SQLLoader
164200 {
165201 return new self ($ options );
166202 }
167203
204+ /**
205+ * Get the SQL Loader binary path.
206+ */
168207 public function getSqlLoaderBinary (): string
169208 {
170209 return config ('sql-loader.sqlldr ' , 'sqlldr ' );
171210 }
172211
212+ /**
213+ * Delete generated files after execution.
214+ */
173215 protected function deleteGeneratedFiles (): void
174216 {
175217 if ($ this ->logPath && File::exists ($ this ->logPath )) {
@@ -196,6 +238,9 @@ protected function deleteGeneratedFiles(): void
196238 }
197239 }
198240
241+ /**
242+ * Set the control file name.
243+ */
199244 public function as (string $ controlFile ): static
200245 {
201246 if (! Str::endsWith ($ controlFile , '.ctl ' )) {
@@ -207,13 +252,19 @@ public function as(string $controlFile): static
207252 return $ this ;
208253 }
209254
255+ /**
256+ * Set the log file path.
257+ */
210258 public function logsTo (string $ path ): static
211259 {
212260 $ this ->logPath = $ path ;
213261
214262 return $ this ;
215263 }
216264
265+ /**
266+ * Check if SQL Loader execution was successful.
267+ */
217268 public function successful (): bool
218269 {
219270 if (is_null ($ this ->result )) {
@@ -223,6 +274,9 @@ public function successful(): bool
223274 return $ this ->result ->successful ();
224275 }
225276
277+ /**
278+ * Get the SQL Loader command, file path and result details.
279+ */
226280 public function debug (): string
227281 {
228282 $ debug = 'Command: ' .PHP_EOL .$ this ->buildCommand ().PHP_EOL .PHP_EOL ;
@@ -237,6 +291,9 @@ public function debug(): string
237291 return $ debug ;
238292 }
239293
294+ /**
295+ * Get the SQL Loader output.
296+ */
240297 public function output (): string
241298 {
242299 if (is_null ($ this ->result )) {
@@ -246,6 +303,9 @@ public function output(): string
246303 return $ this ->result ->output ();
247304 }
248305
306+ /**
307+ * Get the SQL Loader error output.
308+ */
249309 public function errorOutput (): string
250310 {
251311 if (is_null ($ this ->result )) {
@@ -255,13 +315,19 @@ public function errorOutput(): string
255315 return $ this ->result ->errorOutput ();
256316 }
257317
318+ /**
319+ * Set the flag to delete generated files after execution.
320+ */
258321 public function deleteFilesAfterRun (bool $ delete = true ): static
259322 {
260323 $ this ->deleteFiles = $ delete ;
261324
262325 return $ this ;
263326 }
264327
328+ /**
329+ * Get the SQL Loader execution logs.
330+ */
265331 public function logs (): string
266332 {
267333 if ($ this ->logs ) {
@@ -275,6 +341,9 @@ public function logs(): string
275341 return 'No log file available ' ;
276342 }
277343
344+ /**
345+ * Get the SQL Loader process result.
346+ */
278347 public function result (): ProcessResult
279348 {
280349 if (! $ this ->result ) {
@@ -284,6 +353,9 @@ public function result(): ProcessResult
284353 return $ this ->result ;
285354 }
286355
356+ /**
357+ * Set the data to be loaded.
358+ */
287359 public function beginData (array $ data ): static
288360 {
289361 $ this ->inputFiles = [];
0 commit comments