Code Coverage |
||||||||||
Classes and Traits |
Functions and Methods |
Lines |
||||||||
| Total | |
0.00% |
0 / 1 |
|
50.00% |
5 / 10 |
CRAP | |
35.29% |
6 / 17 |
| Container | |
0.00% |
0 / 1 |
|
50.00% |
5 / 10 |
43.78 | |
35.29% |
6 / 17 |
| __construct | |
100.00% |
1 / 1 |
1 | |
100.00% |
2 / 2 |
|||
| getDatabaseConnector | |
0.00% |
0 / 1 |
6.00 | |
0.00% |
0 / 7 |
|||
| getHttpKernel | |
100.00% |
1 / 1 |
1 | |
100.00% |
1 / 1 |
|||
| getSchemaUpdater | |
0.00% |
0 / 1 |
2.00 | |
0.00% |
0 / 1 |
|||
| getRouter | |
100.00% |
1 / 1 |
1 | |
100.00% |
1 / 1 |
|||
| getSystemProxy | |
100.00% |
1 / 1 |
1 | |
100.00% |
1 / 1 |
|||
| getLoginController | |
0.00% |
0 / 1 |
2.00 | |
0.00% |
0 / 1 |
|||
| getRegisterController | |
100.00% |
1 / 1 |
1 | |
100.00% |
1 / 1 |
|||
| getInfoController | |
0.00% |
0 / 1 |
2.00 | |
0.00% |
0 / 1 |
|||
| getIndexController | |
0.00% |
0 / 1 |
2.00 | |
0.00% |
0 / 1 |
|||
| <?php | |
| namespace Luxian\Container; | |
| use Luxian\Common\Configuration; | |
| use Luxian\Common\SystemProxy; | |
| use Luxian\Controller\Index; | |
| use Luxian\Controller\Info; | |
| use Luxian\Controller\Login; | |
| use Luxian\Controller\Register; | |
| use Luxian\Database\DatabaseInterface; | |
| use Luxian\Database\MariaDB; | |
| use Luxian\Database\Schema\Updater; | |
| use Luxian\Http\Kernel; | |
| use Luxian\Http\Request; | |
| use Luxian\Http\Router; | |
| use PDO; | |
| /** @SuppressWarnings(CouplingBetweenObjects) */ | |
| class Container implements ContainerInterface | |
| { | |
| /** @var Configuration */ | |
| protected $config; | |
| /** @var array */ | |
| private $cache = []; | |
| public function __construct(Configuration $config) | |
| { | |
| $this->config = $config; | |
| } | |
| public function getDatabaseConnector(): DatabaseInterface | |
| { | |
| if (!isset($this->cache[__FUNCTION__])) { | |
| $pdo = new PDO( | |
| $this->config->getDataSourceName(), | |
| $this->config->getDatabaseUser(), | |
| $this->config->getDatabasePassword(), | |
| ); | |
| $this->cache[__FUNCTION__] = new MariaDB($pdo); | |
| } | |
| return $this->cache[__FUNCTION__]; | |
| } | |
| public function getHttpKernel(): Kernel | |
| { | |
| return new Kernel($this, $this->getSystemProxy()); | |
| } | |
| public function getSchemaUpdater(): Updater | |
| { | |
| return new Updater($this->getDatabaseConnector()); | |
| } | |
| public function getRouter(): Router | |
| { | |
| return new Router(); | |
| } | |
| public function getSystemProxy(): SystemProxy | |
| { | |
| return new SystemProxy(); | |
| } | |
| public function getLoginController(Request $request): Login | |
| { | |
| return new Login($request, $this); | |
| } | |
| public function getRegisterController(Request $request): Register | |
| { | |
| return new Register($request, $this); | |
| } | |
| public function getInfoController(Request $request): Info | |
| { | |
| return new Info($request, $this); | |
| } | |
| public function getIndexController(Request $request): Index | |
| { | |
| return new Index($request, $this); | |
| } | |
| } |