1 | <?php |
||
2 | /* |
||
3 | * This file is part of the Scrawler package. |
||
4 | * |
||
5 | * (c) Pranjal Pandey <[email protected]> |
||
6 | * |
||
7 | * For the full copyright and license information, please view the LICENSE |
||
8 | * file that was distributed with this source code. |
||
9 | */ |
||
10 | |||
11 | declare(strict_types=1); |
||
12 | |||
13 | namespace Scrawler\Arca\Facade; |
||
14 | |||
15 | use Scrawler\Arca\Collection; |
||
16 | use Scrawler\Arca\Connection; |
||
0 ignored issues
–
show
|
|||
17 | use Scrawler\Arca\Database as DB; |
||
18 | use Scrawler\Arca\Factory\DatabaseFactory; |
||
19 | use Scrawler\Arca\Model; |
||
20 | use Scrawler\Arca\QueryBuilder; |
||
21 | |||
22 | class Database |
||
23 | { |
||
24 | /** |
||
25 | * Store the instance of current connection. |
||
26 | */ |
||
27 | private static DB $database; |
||
28 | |||
29 | /** |
||
30 | * Create a new Database instance. |
||
31 | * |
||
32 | * @param array<mixed> $connectionParams |
||
33 | */ |
||
34 | public static function connect(array $connectionParams): DB |
||
35 | { |
||
36 | $factory = new DatabaseFactory(); |
||
37 | self::$database = $factory->build($connectionParams); |
||
38 | |||
39 | return self::$database; |
||
40 | } |
||
41 | |||
42 | /** |
||
43 | * Get the instance of current connection. |
||
44 | */ |
||
45 | private static function getDB(): DB |
||
46 | { |
||
47 | return self::$database; |
||
48 | } |
||
49 | |||
50 | /** |
||
51 | * Create a new model. |
||
52 | */ |
||
53 | public static function create(string $name): Model |
||
54 | { |
||
55 | return self::getDB()->create($name); |
||
56 | } |
||
57 | |||
58 | /** |
||
59 | * Save a model. |
||
60 | * |
||
61 | * @param string $table |
||
62 | */ |
||
63 | public static function get($table): Collection |
||
64 | { |
||
65 | return self::getDB()->get($table); |
||
66 | } |
||
67 | |||
68 | /** |
||
69 | * Save a model. |
||
70 | */ |
||
71 | public static function getOne(string $table, mixed $id): ?Model |
||
72 | { |
||
73 | return self::getDB()->getOne($table, $id); |
||
74 | } |
||
75 | |||
76 | /** |
||
77 | * Execure a raw sql query. |
||
78 | * |
||
79 | * @return int|numeric-string |
||
0 ignored issues
–
show
|
|||
80 | */ |
||
81 | public static function exec(string $sql): int|string |
||
82 | { |
||
83 | return self::getDB()->exec($sql); |
||
84 | } |
||
85 | |||
86 | /** |
||
87 | * Delete a model. |
||
88 | */ |
||
89 | public static function delete(Model $model): mixed |
||
90 | { |
||
91 | return self::getDB()->delete($model); |
||
92 | } |
||
93 | |||
94 | /** |
||
95 | * QUery builder to find a model. |
||
96 | */ |
||
97 | public static function find(string $table): QueryBuilder |
||
98 | { |
||
99 | return self::getDB()->find($table); |
||
100 | } |
||
101 | } |
||
102 |
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:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths