Lines
n/a
0 / 0
Functions and Methods
n/a
0 / 0
Classes and Traits
n/a
0 / 0
| Name | Lines | Functions and Methods | CRAP | Classes and Traits | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| LogOperatorMiddleware | n/a | 0 / 0 | n/a | 0 / 0 | 2 | n/a | 0 / 0 | |||
| __invoke | n/a | 0 / 0 | n/a | 0 / 0 | 1 | |||||
| getAuthorityWithoutPassword | n/a | 0 / 0 | n/a | 0 / 0 | 1 | |||||
| 1 | <?php | |
| 2 | ||
| 3 | namespace BO\Zmsbackend\Helper; | |
| 4 | ||
| 5 | use Psr\Http\Message\ServerRequestInterface; | |
| 6 | use Psr\Http\Server\RequestHandlerInterface; | |
| 7 | ||
| 8 | /** | |
| 9 | * @codeCoverageIgnore | |
| 10 | * | |
| 11 | */ | |
| 12 | class LogOperatorMiddleware | |
| 13 | { | |
| 14 | public function __invoke(ServerRequestInterface $request, RequestHandlerInterface $next) | |
| 15 | { | |
| 16 | $authority = $request->getUri()->getAuthority(); | |
| 17 | \BO\Zmsbackend\Log\Service\Log::$operator = $this->getAuthorityWithoutPassword($authority) . '@' . gethostname(); | |
| 18 | ||
| 19 | return $next->handle($request); | |
| 20 | } | |
| 21 | ||
| 22 | /** | |
| 23 | * @return null|string|string[] | |
| 24 | * | |
| 25 | */ | |
| 26 | private function getAuthorityWithoutPassword(string $authority): array|string|null | |
| 27 | { | |
| 28 | $regex = '/((:)(.+)(?=@))/'; | |
| 29 | return preg_replace($regex, '', $authority); | |
| 30 | } | |
| 31 | } |