Passed
Push — main ( e2fa8b...75aa7b )
by Thierry
39:25 queued 27:26
created

ExportTrait::exportDatabases()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
c 0
b 0
f 0
nc 1
nop 2
dl 0
loc 4
rs 10
1
<?php
2
3
namespace Lagdo\DbAdmin\Db\Traits;
4
5
use Lagdo\DbAdmin\Db\Facades\ExportFacade;
6
7
use function array_keys;
8
9
/**
10
 * Facade to export functions
11
 */
12
trait ExportTrait
13
{
14
    use AbstractTrait;
15
16
    /**
17
     * Get the facade
18
     *
19
     * @return ExportFacade
20
     */
21
    protected function exportFacade(): ExportFacade
22
    {
23
        return $this->di()->g(ExportFacade::class);
24
    }
25
26
    /**
27
     * Get data for export
28
     *
29
     * @return array
30
     */
31
    public function getExportOptions(): array
32
    {
33
        $this->connectToDatabase();
34
        $this->breadcrumbs(true)->item($this->utils->trans->lang('Export'));
35
        return $this->exportFacade()->getExportOptions($this->dbName);
36
    }
37
38
    /**
39
     * @return array
40
     */
41
    public function getSelectValues(): array
42
    {
43
        $this->connectToServer();
44
        return [
45
            'output' => array_keys($this->exportFacade()->getSelectOutputValues()),
46
            'format' => array_keys($this->exportFacade()->getSelectFormatValues()),
47
            'db_style' => $this->exportFacade()->getSelectDatabaseValues(),
48
            'table_style' => $this->exportFacade()->getSelectTableValues(),
49
            'data_style' => $this->exportFacade()->getSelectDataValues(),
50
        ];
51
    }
52
53
    /**
54
     * Export databases
55
     * The databases and tables parameters are array where the keys are names and the values
56
     * are boolean which indicate whether the corresponding data should be exported too.
57
     *
58
     * @param array  $databases     The databases to dump
59
     * @param array  $dumpOptions   The export options
60
     *
61
     * @return array|string
62
     */
63
    public function exportDatabases(array $databases, array $dumpOptions)
64
    {
65
        $this->connectToServer();
66
        return $this->exportFacade()->exportDatabases($databases, $dumpOptions);
67
    }
68
}
69