ImportTrait::importFacade()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Lagdo\DbAdmin\Db\Traits;
4
5
use Lagdo\DbAdmin\Db\Facades\ImportFacade;
6
7
/**
8
 * Facade to import functions
9
 */
10
trait ImportTrait
11
{
12
    use AbstractTrait;
13
14
    /**
15
     * Get the facade
16
     *
17
     * @return ImportFacade
18
     */
19
    protected function importFacade(): ImportFacade
20
    {
21
        return $this->di()->g(ImportFacade::class);
22
    }
23
24
    /**
25
     * Get data for import
26
     *
27
     * @return array
28
     */
29
    public function getImportOptions(): array
30
    {
31
        $this->connectToDatabase();
32
        $this->breadcrumbs(true)->item($this->utils->trans->lang('Import'));
33
        return $this->importFacade()->getImportOptions();
34
    }
35
36
    /**
37
     * Run queries from uploaded files
38
     *
39
     * @param array  $files         The uploaded files
40
     * @param bool   $errorStops    Stop executing the requests in case of error
41
     * @param bool   $onlyErrors    Return only errors
42
     *
43
     * @return array
44
     */
45
    public function executeSqlFiles(array $files, bool $errorStops, bool $onlyErrors): array
46
    {
47
        $this->connectToSchema();
48
        return $this->importFacade()->executeSqlFiles($files, $errorStops, $onlyErrors);
49
    }
50
}
51