ExportTrait   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 43
Duplicated Lines 0 %

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A exportDatabases() 0 4 1
A getExportOptions() 0 5 1
A exportFacade() 0 3 1
1
<?php
2
3
namespace Lagdo\DbAdmin\Db\Traits;
4
5
use Lagdo\DbAdmin\Db\Facades\ExportFacade;
6
7
/**
8
 * Facade to export functions
9
 */
10
trait ExportTrait
11
{
12
    use AbstractTrait;
13
14
    /**
15
     * Get the facade
16
     *
17
     * @return ExportFacade
18
     */
19
    protected function exportFacade(): ExportFacade
20
    {
21
        return $this->di()->g(ExportFacade::class);
22
    }
23
24
    /**
25
     * Get data for export
26
     *
27
     * @param string $database      The database name
28
     *
29
     * @return array
30
     */
31
    public function getExportOptions(string $database = ''): array
32
    {
33
        $this->connectToDatabase();
34
        $this->breadcrumbs(true)->item($this->utils->trans->lang('Export'));
35
        return $this->exportFacade()->getExportOptions($database);
36
    }
37
38
    /**
39
     * Export databases
40
     * The databases and tables parameters are array where the keys are names and the values
41
     * are boolean which indicate whether the corresponding data should be exported too.
42
     *
43
     * @param array  $databases     The databases to dump
44
     * @param array  $tables        The tables to dump
45
     * @param array  $dumpOptions   The export options
46
     *
47
     * @return array|string
48
     */
49
    public function exportDatabases(array $databases, array $tables, array $dumpOptions)
50
    {
51
        $this->connectToServer();
52
        return $this->exportFacade()->exportDatabases($databases, $tables, $dumpOptions);
53
    }
54
}
55