]> git.mxchange.org Git - friendica.git/blob - src/BaseObject.php
Use direct logic
[friendica.git] / src / BaseObject.php
1 <?php
2 /**
3  * @file src/BaseObject.php
4  */
5 namespace Friendica;
6
7 require_once __DIR__ . '/../boot.php';
8
9 use Friendica\Network\HTTPException\InternalServerErrorException;
10
11 /**
12  * Basic object
13  *
14  * Contains what is useful to any object
15  */
16 class BaseObject
17 {
18         private static $app = null;
19
20         /**
21          * Get the app
22          *
23          * Same as get_app from boot.php
24          *
25          * @return App
26          * @throws \Exception
27          */
28         public static function getApp()
29         {
30                 if (empty(self::$app)) {
31                         throw new InternalServerErrorException('App isn\'t initialized.');
32                 }
33
34                 return self::$app;
35         }
36
37         /**
38          * Set the app
39          *
40          * @param App $app App
41          *
42          * @return void
43          */
44         public static function setApp(App $app)
45         {
46                 self::$app = $app;
47         }
48 }