Passed
Push — main ( a44b7a...ef9f8a )
by Pranjal
02:25
created

Connection::isUsingUUID()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 2
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 2
rs 10
1
<?php
2
3
declare(strict_types=1);
4
namespace Scrawler\Arca;
5
6
use \Doctrine\DBAL\Connection as DBALConnection;
0 ignored issues
show
Bug introduced by
The type \Doctrine\DBAL\Connection was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
7
use Doctrine\DBAL\Platforms\AbstractPlatform;
8
use \Doctrine\DBAL\Schema\AbstractSchemaManager;
0 ignored issues
show
Bug introduced by
The type \Doctrine\DBAL\Schema\AbstractSchemaManager was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
9
use \Scrawler\Arca\Manager\RecordManager;
0 ignored issues
show
Bug introduced by
The type \Scrawler\Arca\Manager\RecordManager was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
10
use \Scrawler\Arca\Manager\TableManager;
0 ignored issues
show
Bug introduced by
The type \Scrawler\Arca\Manager\TableManager was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
11
use \Scrawler\Arca\Manager\ModelManager;
0 ignored issues
show
Bug introduced by
The type \Scrawler\Arca\Manager\ModelManager was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
12
use Ramsey\Uuid\Uuid;
13
14
15
class Connection{
16
17
    private DBALConnection $connection;
18
    private AbstractSchemaManager $SchemaManager;
19
    private AbstractPlatform $platform;
20
    private RecordManager $RecordManager;
21
    private TableManager $TableManager;
22
    private ModelManager $ModelManager;
23
    private bool $isUsingUUID;
24
    private string $connectionId;
25
26
    public function __construct(array $connectionParams)
27
    {
28
        $this->connectionId = UUID::uuid4()->toString();
29
        if(isset($connectionParams['useUUID']) && $connectionParams['useUUID']){
30
            $this->isUsingUUID = true;
31
        }else{
32
            $this->isUsingUUID = false;
33
        }
34
        unset($connectionParams['useUUID']);
35
        $this->connection = \Doctrine\DBAL\DriverManager::getConnection($connectionParams);
36
        $this->SchemaManager = $this->connection->createSchemaManager();
37
        $this->platform = $this->connection->getDatabasePlatform();
38
        $this->ModelManager = new ModelManager();
39
        $this->RecordManager = new RecordManager($this->connection,$this->ModelManager,$this->isUsingUUID);
40
        $this->TableManager = new TableManager($this->connection,$this->isUsingUUID);
41
        $this->ModelManager->setConnection($this);
42
    }
43
44
    public function getSchemaManager(){
45
        return $this->SchemaManager;
46
    }
47
48
    public function getPlatform(){
49
        return $this->platform;
50
    }
51
52
    public function isUsingUUID(){
53
        return $this->isUsingUUID;
54
    }
55
56
    public function getRecordManager(){
57
        return $this->RecordManager;
58
    }
59
60
    public function getTableManager(){
61
        return $this->TableManager;
62
    }
63
64
    public function getModelManager(){
65
        return $this->ModelManager;
66
    }
67
68
    public function getConnectionId(){
69
        return $this->connectionId;
70
    }
71
72
    function __call($method, $args) {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
73
        return call_user_func_array(array($this->connection, $method), $args);
74
    }
75
    
76
77
}