@@ -80,8 +80,8 @@ discard block |
||
| 80 | 80 | */ |
| 81 | 81 | public function serve() |
| 82 | 82 | { |
| 83 | - foreach ($this->dispatchers as $dispatcher) { |
|
| 84 | - if ($dispatcher->canServe()) { |
|
| 83 | + foreach ($this->dispatchers as $dispatcher){ |
|
| 84 | + if ($dispatcher->canServe()){ |
|
| 85 | 85 | ContainerScope::runScope($this->container, function () use ($dispatcher) { |
| 86 | 86 | $dispatcher->serve(); |
| 87 | 87 | }); |
@@ -105,25 +105,25 @@ discard block |
||
| 105 | 105 | */ |
| 106 | 106 | protected function mapDirectories(array $directories): array |
| 107 | 107 | { |
| 108 | - if (!isset($directories['root'])) { |
|
| 108 | + if (!isset($directories['root'])){ |
|
| 109 | 109 | throw new FrameworkException("Missing required directory `root`."); |
| 110 | 110 | } |
| 111 | 111 | |
| 112 | - if (!isset($directories['app'])) { |
|
| 113 | - $directories['app'] = $directories['root'] . '/app/'; |
|
| 112 | + if (!isset($directories['app'])){ |
|
| 113 | + $directories['app'] = $directories['root'].'/app/'; |
|
| 114 | 114 | } |
| 115 | 115 | |
| 116 | 116 | return array_merge($directories, [ |
| 117 | 117 | // public root |
| 118 | - 'public' => $directories['root'] . '/public/', |
|
| 118 | + 'public' => $directories['root'].'/public/', |
|
| 119 | 119 | |
| 120 | 120 | // application directories |
| 121 | - 'config' => $directories['app'] . '/config/', |
|
| 122 | - 'resources' => $directories['app'] . '/resources/', |
|
| 121 | + 'config' => $directories['app'].'/config/', |
|
| 122 | + 'resources' => $directories['app'].'/resources/', |
|
| 123 | 123 | |
| 124 | 124 | // data directories |
| 125 | - 'runtime' => $directories['app'] . '/runtime/', |
|
| 126 | - 'cache' => $directories['app'] . '/runtime/cache/', |
|
| 125 | + 'runtime' => $directories['app'].'/runtime/', |
|
| 126 | + 'cache' => $directories['app'].'/runtime/cache/', |
|
| 127 | 127 | ]); |
| 128 | 128 | } |
| 129 | 129 | |
@@ -152,7 +152,7 @@ discard block |
||
| 152 | 152 | EnvironmentInterface $environment = null, |
| 153 | 153 | bool $handleErrors = true |
| 154 | 154 | ): self { |
| 155 | - if ($handleErrors) { |
|
| 155 | + if ($handleErrors){ |
|
| 156 | 156 | ExceptionHandler::register(); |
| 157 | 157 | } |
| 158 | 158 | |
@@ -162,11 +162,11 @@ discard block |
||
| 162 | 162 | $environment ?? new Environment() |
| 163 | 163 | ); |
| 164 | 164 | |
| 165 | - try { |
|
| 165 | + try{ |
|
| 166 | 166 | ContainerScope::runScope($core->container, function () use ($core) { |
| 167 | 167 | $core->bootload()->bootstrap(); |
| 168 | 168 | }); |
| 169 | - } catch (\Throwable $e) { |
|
| 169 | + }catch (\Throwable $e){ |
|
| 170 | 170 | ExceptionHandler::handleException($e); |
| 171 | 171 | } |
| 172 | 172 | |
@@ -80,9 +80,12 @@ discard block |
||
| 80 | 80 | */ |
| 81 | 81 | public function serve() |
| 82 | 82 | { |
| 83 | - foreach ($this->dispatchers as $dispatcher) { |
|
| 84 | - if ($dispatcher->canServe()) { |
|
| 85 | - ContainerScope::runScope($this->container, function () use ($dispatcher) { |
|
| 83 | + foreach ($this->dispatchers as $dispatcher) |
|
| 84 | + { |
|
| 85 | + if ($dispatcher->canServe()) |
|
| 86 | + { |
|
| 87 | + ContainerScope::runScope($this->container, function () use ($dispatcher) |
|
| 88 | + { |
|
| 86 | 89 | $dispatcher->serve(); |
| 87 | 90 | }); |
| 88 | 91 | return; |
@@ -105,11 +108,13 @@ discard block |
||
| 105 | 108 | */ |
| 106 | 109 | protected function mapDirectories(array $directories): array |
| 107 | 110 | { |
| 108 | - if (!isset($directories['root'])) { |
|
| 111 | + if (!isset($directories['root'])) |
|
| 112 | + { |
|
| 109 | 113 | throw new FrameworkException("Missing required directory `root`."); |
| 110 | 114 | } |
| 111 | 115 | |
| 112 | - if (!isset($directories['app'])) { |
|
| 116 | + if (!isset($directories['app'])) |
|
| 117 | + { |
|
| 113 | 118 | $directories['app'] = $directories['root'] . '/app/'; |
| 114 | 119 | } |
| 115 | 120 | |
@@ -152,7 +157,8 @@ discard block |
||
| 152 | 157 | EnvironmentInterface $environment = null, |
| 153 | 158 | bool $handleErrors = true |
| 154 | 159 | ): self { |
| 155 | - if ($handleErrors) { |
|
| 160 | + if ($handleErrors) |
|
| 161 | + { |
|
| 156 | 162 | ExceptionHandler::register(); |
| 157 | 163 | } |
| 158 | 164 | |
@@ -162,11 +168,15 @@ discard block |
||
| 162 | 168 | $environment ?? new Environment() |
| 163 | 169 | ); |
| 164 | 170 | |
| 165 | - try { |
|
| 166 | - ContainerScope::runScope($core->container, function () use ($core) { |
|
| 171 | + try |
|
| 172 | + { |
|
| 173 | + ContainerScope::runScope($core->container, function () use ($core) |
|
| 174 | + { |
|
| 167 | 175 | $core->bootload()->bootstrap(); |
| 168 | 176 | }); |
| 169 | - } catch (\Throwable $e) { |
|
| 177 | + } |
|
| 178 | + catch (\Throwable $e) |
|
| 179 | + { |
|
| 170 | 180 | ExceptionHandler::handleException($e); |
| 171 | 181 | } |
| 172 | 182 | |
@@ -39,7 +39,7 @@ discard block |
||
| 39 | 39 | */ |
| 40 | 40 | public function getID(): string |
| 41 | 41 | { |
| 42 | - if (empty($this->id)) { |
|
| 42 | + if (empty($this->id)){ |
|
| 43 | 43 | $this->id = md5(serialize($this->values)); |
| 44 | 44 | } |
| 45 | 45 | |
@@ -62,7 +62,7 @@ discard block |
||
| 62 | 62 | */ |
| 63 | 63 | public function get(string $name, $default = null) |
| 64 | 64 | { |
| 65 | - if (isset($this->values[$name])) { |
|
| 65 | + if (isset($this->values[$name])){ |
|
| 66 | 66 | return $this->normalize($this->values[$name]); |
| 67 | 67 | } |
| 68 | 68 | |
@@ -75,12 +75,12 @@ discard block |
||
| 75 | 75 | */ |
| 76 | 76 | protected function normalize($value): ?string |
| 77 | 77 | { |
| 78 | - if (!is_string($value)) { |
|
| 78 | + if (!is_string($value)){ |
|
| 79 | 79 | return $value; |
| 80 | 80 | } |
| 81 | 81 | |
| 82 | 82 | $alias = strtolower($value); |
| 83 | - if (isset(self::VALUE_MAP[$alias])) { |
|
| 83 | + if (isset(self::VALUE_MAP[$alias])){ |
|
| 84 | 84 | return self::VALUE_MAP[$alias]; |
| 85 | 85 | } |
| 86 | 86 | |
@@ -39,7 +39,8 @@ discard block |
||
| 39 | 39 | */ |
| 40 | 40 | public function getID(): string |
| 41 | 41 | { |
| 42 | - if (empty($this->id)) { |
|
| 42 | + if (empty($this->id)) |
|
| 43 | + { |
|
| 43 | 44 | $this->id = md5(serialize($this->values)); |
| 44 | 45 | } |
| 45 | 46 | |
@@ -62,7 +63,8 @@ discard block |
||
| 62 | 63 | */ |
| 63 | 64 | public function get(string $name, $default = null) |
| 64 | 65 | { |
| 65 | - if (isset($this->values[$name])) { |
|
| 66 | + if (isset($this->values[$name])) |
|
| 67 | + { |
|
| 66 | 68 | return $this->normalize($this->values[$name]); |
| 67 | 69 | } |
| 68 | 70 | |
@@ -75,12 +77,14 @@ discard block |
||
| 75 | 77 | */ |
| 76 | 78 | protected function normalize($value): ?string |
| 77 | 79 | { |
| 78 | - if (!is_string($value)) { |
|
| 80 | + if (!is_string($value)) |
|
| 81 | + { |
|
| 79 | 82 | return $value; |
| 80 | 83 | } |
| 81 | 84 | |
| 82 | 85 | $alias = strtolower($value); |
| 83 | - if (isset(self::VALUE_MAP[$alias])) { |
|
| 86 | + if (isset(self::VALUE_MAP[$alias])) |
|
| 87 | + { |
|
| 84 | 88 | return self::VALUE_MAP[$alias]; |
| 85 | 89 | } |
| 86 | 90 | |