CommandTrait::commandFacade()   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\CommandFacade;
6
7
/**
8
 * Facade to command functions
9
 */
10
trait CommandTrait
11
{
12
    use AbstractTrait;
13
14
    /**
15
     * Get the facade
16
     *
17
     * @return CommandFacade
18
     */
19
    protected function commandFacade(): CommandFacade
20
    {
21
        return $this->di()->g(CommandFacade::class);
22
    }
23
24
    /**
25
     * Prepare a query
26
     *
27
     * @return void
28
     */
29
    public function prepareCommand()
30
    {
31
        $this->bcdb()->breadcrumb($this->utils->trans->lang('Query'));
32
    }
33
34
    /**
35
     * Execute a query
36
     *
37
     * @param string $query         The query to be executed
38
     * @param int    $limit         The max number of rows to return
39
     * @param bool   $errorStops    Stop executing the requests in case of error
40
     * @param bool   $onlyErrors    Return only errors
41
     *
42
     * @return array
43
     */
44
    public function executeCommands(string $query, int $limit, bool $errorStops, bool $onlyErrors): array
45
    {
46
        $this->connectToSchema();
47
        return $this->commandFacade()->executeCommands($query, $limit, $errorStops, $onlyErrors);
48
    }
49
}
50