CommandTrait   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 6
dl 0
loc 38
rs 10
c 0
b 0
f 0
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A prepareCommand() 0 3 1
A commandFacade() 0 3 1
A executeCommands() 0 4 1
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