SqlExecutorFactory::createInProcessExecutor()   A
last analyzed

Complexity

Conditions 4
Paths 5

Size

Total Lines 18
Code Lines 12

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 1
Metric Value
eloc 12
c 2
b 0
f 1
dl 0
loc 18
rs 9.8666
cc 4
nc 5
nop 4
1
<?php
2
0 ignored issues
show
Coding Style introduced by
Missing file doc comment
Loading history...
3
namespace Db3v4l\Service;
4
5
use Db3v4l\API\Interfaces\SqlExecutor\Forked\CommandExecutor as ForkedCommandExecutor;
6
use Db3v4l\API\Interfaces\SqlExecutor\Forked\FileExecutor as ForkedFileExecutor;
7
use Db3v4l\API\Interfaces\SqlExecutor\InProcess\CommandExecutor as InProcessCommandExecutor;
8
use Db3v4l\API\Interfaces\SqlExecutor\InProcess\FileExecutor as InProcessFileExecutor;
9
use Db3v4l\Core\SqlExecutor\Forked\NativeClient;
10
use Db3v4l\Core\SqlExecutor\Forked\Doctrine as ForkedDoctrine;
11
use Db3v4l\Core\SqlExecutor\Forked\PDO as ForkedPDO;
12
use Db3v4l\Core\SqlExecutor\Forked\TimedExecutor as ForkedTimeExecutor;
13
use Db3v4l\Core\SqlExecutor\InProcess\Doctrine as InProcessDoctrine;
14
use Db3v4l\Core\SqlExecutor\InProcess\PDO as InProcessPDO;
15
use Db3v4l\Core\SqlExecutor\InProcess\TimedExecutor as InProcessTimedExecutor;
16
17
class SqlExecutorFactory
0 ignored issues
show
Coding Style introduced by
Missing doc comment for class SqlExecutorFactory
Loading history...
18
{
19
    /** @var DatabaseConfigurationManager $dbConfigurationManager */
0 ignored issues
show
Coding Style introduced by
The open comment tag must be the only content on the line
Loading history...
Coding Style introduced by
Missing short description in doc comment
Loading history...
Coding Style introduced by
The close comment tag must be the only content on the line
Loading history...
20
    protected $dbConfigurationManager;
21
22
    public function __construct(DatabaseConfigurationManager $dbConfigurationManager)
0 ignored issues
show
Coding Style introduced by
Missing doc comment for function __construct()
Loading history...
23
    {
24
        $this->dbConfigurationManager = $dbConfigurationManager;
25
    }
26
27
    /**
0 ignored issues
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
28
     * @param string $instanceName
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
Coding Style introduced by
Tag value for @param tag indented incorrectly; expected 2 spaces but found 1
Loading history...
29
     * @param array $databaseConnectionConfiguration
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
Coding Style introduced by
Expected 2 spaces after parameter type; 1 found
Loading history...
Coding Style introduced by
Tag value for @param tag indented incorrectly; expected 2 spaces but found 1
Loading history...
30
     * @param string $executionStrategy
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
Coding Style introduced by
Tag value for @param tag indented incorrectly; expected 2 spaces but found 1
Loading history...
31
     * @param bool $timed
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
Coding Style introduced by
Expected 3 spaces after parameter type; 1 found
Loading history...
Coding Style introduced by
Tag value for @param tag indented incorrectly; expected 2 spaces but found 1
Loading history...
32
     * @return ForkedCommandExecutor|ForkedFileExecutor
0 ignored issues
show
Coding Style introduced by
Tag @return cannot be grouped with parameter tags in a doc comment
Loading history...
33
     * @throws \OutOfBoundsException
0 ignored issues
show
Coding Style introduced by
Tag @throws cannot be grouped with parameter tags in a doc comment
Loading history...
34
     */
35
    public function createForkedExecutor($instanceName, array $databaseConnectionConfiguration, $executionStrategy = NativeClient::EXECUTION_STRATEGY, $timed = true)
36
    {
37
        switch ($executionStrategy) {
38
            case ForkedDoctrine::EXECUTION_STRATEGY:
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected 8 spaces, found 12
Loading history...
39
                $executor = new ForkedDoctrine($databaseConnectionConfiguration);
40
                $executor->setInstanceName($instanceName);
41
                $executor->setDbConfigurationManager($this->dbConfigurationManager);
42
                break;
43
            case NativeClient::EXECUTION_STRATEGY:
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected 8 spaces, found 12
Loading history...
44
                $executor = new NativeClient($databaseConnectionConfiguration);
45
                break;
46
            case ForkedPDO::EXECUTION_STRATEGY:
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected 8 spaces, found 12
Loading history...
47
                $executor = new ForkedPDO($databaseConnectionConfiguration);
48
                $executor->setInstanceName($instanceName);
49
                $executor->setDbConfigurationManager($this->dbConfigurationManager);
50
                break;
51
            default:
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected 8 spaces, found 12
Loading history...
52
                throw new \OutOfBoundsException("Unsupported execution strategy '$executionStrategy'");
53
        }
54
55
        if ($timed) {
56
            $executor = new ForkedTimeExecutor($executor);
57
        }
58
59
        return $executor;
60
    }
61
62
    /**
0 ignored issues
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
63
     * @param string $instanceName
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
Coding Style introduced by
Tag value for @param tag indented incorrectly; expected 2 spaces but found 1
Loading history...
64
     * @param array $databaseConnectionConfiguration
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
Coding Style introduced by
Expected 2 spaces after parameter type; 1 found
Loading history...
Coding Style introduced by
Tag value for @param tag indented incorrectly; expected 2 spaces but found 1
Loading history...
65
     * @param string $executionStrategy
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
Coding Style introduced by
Tag value for @param tag indented incorrectly; expected 2 spaces but found 1
Loading history...
66
     * @param bool $timed
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
Coding Style introduced by
Expected 3 spaces after parameter type; 1 found
Loading history...
Coding Style introduced by
Tag value for @param tag indented incorrectly; expected 2 spaces but found 1
Loading history...
67
     * @return InProcessCommandExecutor|InProcessFileExecutor
0 ignored issues
show
Coding Style introduced by
Tag @return cannot be grouped with parameter tags in a doc comment
Loading history...
68
     * @throws \OutOfBoundsException
0 ignored issues
show
Coding Style introduced by
Tag @throws cannot be grouped with parameter tags in a doc comment
Loading history...
69
     */
70
    public function createInProcessExecutor($instanceName, array $databaseConnectionConfiguration, $executionStrategy = 'Doctrine', $timed = true)
0 ignored issues
show
Unused Code introduced by
The parameter $instanceName is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

70
    public function createInProcessExecutor(/** @scrutinizer ignore-unused */ $instanceName, array $databaseConnectionConfiguration, $executionStrategy = 'Doctrine', $timed = true)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
71
    {
72
        switch ($executionStrategy) {
73
            case InProcessDoctrine::EXECUTION_STRATEGY:
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected 8 spaces, found 12
Loading history...
74
                $executor = new InProcessDoctrine($databaseConnectionConfiguration);
75
                break;
76
            case InProcessPDO::EXECUTION_STRATEGY:
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected 8 spaces, found 12
Loading history...
77
                $executor = new InProcessPDO($databaseConnectionConfiguration);
78
                break;
79
            default:
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected 8 spaces, found 12
Loading history...
80
                throw new \OutOfBoundsException("Unsupported execution strategy '$executionStrategy'");
81
        }
82
83
        if ($timed) {
84
            $executor = new InprocessTimedExecutor($executor);
85
        }
86
87
        return $executor;
88
    }
89
}
90