Passed
Push — main ( ce0e6f...632f8e )
by Pranjal
02:11
created

Database   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 10
c 1
b 0
f 0
dl 0
loc 22
rs 10
wmc 4

3 Methods

Rating   Name   Duplication   Size   Complexity  
A connect() 0 11 2
A getDB() 0 2 1
A create() 0 2 1
1
<?php
2
declare(strict_types=1);
3
4
namespace Scrawler\Arca\Facade;
5
6
use Scrawler\Arca\Manager\TableManager;
7
use Scrawler\Arca\Manager\RecordManager;
8
use Scrawler\Arca\Manager\ModelManager;
9
use Scrawler\Arca\Database as DB;
10
11
class Database {
12
    private static $database;
13
14
    public static function connect(array $connectionParams){
15
        
16
        if(self::$database == null)
17
        {
18
            $connection = \Doctrine\DBAL\DriverManager::getConnection($connectionParams);
19
            self::$database = new DB($connection);
20
            self::$database->setManagers(new TableManager(self::$database),new RecordManager(self::$database),new ModelManager(self::$database));
21
            return self::$database;
22
        }
23
24
            return self::$database;
25
    }
26
27
    private static function getDB(){
0 ignored issues
show
Unused Code introduced by
The method getDB() is not used, and could be removed.

This check looks for private methods that have been defined, but are not used inside the class.

Loading history...
28
        return self::$database;
29
    }
30
31
    public static function create($name){
32
        return getDB()->create($name);
0 ignored issues
show
Bug introduced by
The function getDB was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

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

32
        return /** @scrutinizer ignore-call */ getDB()->create($name);
Loading history...
33
    }
34
}