1 | <?php |
||
4 | class DatabaseManager |
||
5 | { |
||
6 | /** @var \Wandu\Database\Connector[] */ |
||
7 | protected $connectors = []; |
||
8 | |||
9 | /** @var \Wandu\Database\Contracts\Connection[] */ |
||
10 | protected $connections = []; |
||
11 | |||
12 | /** @var \Wandu\Database\Repository[] */ |
||
13 | protected $repositories = []; |
||
14 | |||
15 | 19 | public function __construct(Configuration $config) |
|
19 | |||
20 | /** |
||
21 | * @param array|\Wandu\Database\Connector $connector |
||
22 | * @param string $name |
||
23 | * @return \Wandu\Database\Contracts\Connection |
||
24 | */ |
||
25 | 19 | public function connect($connector, $name = 'default') |
|
37 | |||
38 | /** |
||
39 | * @param string $name |
||
40 | * @return \Wandu\Database\Contracts\Connection |
||
41 | */ |
||
42 | public function connection($name = 'default') |
||
46 | |||
47 | /** |
||
48 | * @param string $class |
||
49 | * @return \Wandu\Database\Repository |
||
50 | */ |
||
51 | 15 | public function repository(string $class): Repository |
|
69 | } |
||
70 |
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: