Total Complexity | 5 |
Total Lines | 72 |
Duplicated Lines | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
19 | abstract class AbstractApplication |
||
20 | { |
||
21 | /** |
||
22 | * 应用程序实例 |
||
23 | * |
||
24 | * @var \poker\application\AbstractApplication |
||
25 | */ |
||
26 | protected static $instance; |
||
27 | |||
28 | /** |
||
29 | * 应用程序开始时间 |
||
30 | * |
||
31 | * @var float |
||
32 | */ |
||
33 | protected $startTime; |
||
34 | |||
35 | /** |
||
36 | * 应用程序根路径地址 |
||
37 | * |
||
38 | * @var string |
||
39 | */ |
||
40 | protected $rootPath; |
||
41 | |||
42 | /** |
||
43 | * 容器实例 |
||
44 | * |
||
45 | * @var \poker\container\Container |
||
46 | */ |
||
47 | protected $container; |
||
48 | |||
49 | /** |
||
50 | * 构造函数 |
||
51 | * |
||
52 | * @param string $rootPath 应用程序根路径地址 |
||
53 | */ |
||
54 | public function __construct(string $rootPath) |
||
55 | { |
||
56 | $this->startTime = microtime(true); |
||
57 | $this->rootPath = rtrim($rootPath, '\\/'); |
||
58 | $this->container = Container::getInstance(); |
||
59 | |||
60 | // 应用程序初始化 |
||
61 | $this->initialize(); |
||
62 | } |
||
63 | |||
64 | /** |
||
65 | * 返回应用程序实例 |
||
66 | * |
||
67 | * @param string $rootPath 应用程序根路径地址 |
||
68 | * @return \poker\application\AbstractApplication |
||
69 | */ |
||
70 | public static function getInstance(string $rootPath = null): AbstractApplication |
||
77 | } |
||
78 | |||
79 | /** |
||
80 | * 应用程序初始化 |
||
81 | */ |
||
82 | protected function initialize(): void |
||
85 | } |
||
86 | |||
87 | /** |
||
88 | * 运行应用程序 |
||
89 | */ |
||
90 | abstract public function run(); |
||
91 | } |
||
92 |