Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
62.50% covered (warning)
62.50%
10 / 16
33.33% covered (danger)
33.33%
2 / 6
CRAP
0.00% covered (danger)
0.00%
0 / 1
Controller
62.50% covered (warning)
62.50%
10 / 16
33.33% covered (danger)
33.33%
2 / 6
17.38
0.00% covered (danger)
0.00%
0 / 1
 sessionDAO
66.67% covered (warning)
66.67%
2 / 3
0.00% covered (danger)
0.00%
0 / 1
2.15
 adminDAO
66.67% covered (warning)
66.67%
2 / 3
0.00% covered (danger)
0.00%
0 / 1
2.15
 testDAO
66.67% covered (warning)
66.67%
2 / 3
0.00% covered (danger)
0.00%
0 / 1
2.15
 superAdminDAO
0.00% covered (danger)
0.00%
0 / 3
0.00% covered (danger)
0.00%
0 / 1
6
 workspaceDAO
100.00% covered (success)
100.00%
3 / 3
100.00% covered (success)
100.00%
1 / 1
2
 authToken
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
1<?php
2
3use Slim\Http\ServerRequest as Request;
4
5abstract class Controller {
6  protected static $_adminDAO; // TODO refactor DAO to be static, than this would not be needed
7  protected static $_superAdminDAO;
8  protected static $_sessionDAO;
9  protected static $_testDAO;
10  protected static $_workspaceDAO;
11
12  protected static function sessionDAO(): SessionDAO {
13    if (!self::$_sessionDAO) {
14      self::$_sessionDAO = new SessionDAO();
15    }
16
17    return self::$_sessionDAO;
18  }
19
20  protected static function adminDAO(): AdminDAO {
21    if (!self::$_adminDAO) {
22      self::$_adminDAO = new AdminDAO();
23    }
24
25    return self::$_adminDAO;
26  }
27
28  protected static function testDAO(): TestDAO {
29    if (!self::$_testDAO) {
30      self::$_testDAO = new TestDAO();
31    }
32
33    return self::$_testDAO;
34  }
35
36  protected static function superAdminDAO(): SuperAdminDAO {
37    if (!self::$_superAdminDAO) {
38      self::$_superAdminDAO = new SuperAdminDAO();
39    }
40
41    return self::$_superAdminDAO;
42  }
43
44  protected static function workspaceDAO(int $workspaceId): WorkspaceDAO {
45    if (!self::$_workspaceDAO) {
46      self::$_workspaceDAO = new WorkspaceDAO($workspaceId, '');
47    }
48
49    return self::$_workspaceDAO;
50  }
51
52  protected static function authToken(Request $request): AuthToken {
53    return $request->getAttribute('AuthToken');
54  }
55}