ImportTrait   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 8
dl 0
loc 39
rs 10
c 0
b 0
f 0
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A importFacade() 0 3 1
A getImportOptions() 0 5 1
A executeSqlFiles() 0 4 1
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