Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
n/a
0 / 0
n/a
0 / 0
CRAP
n/a
0 / 0
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
3namespace BO\Zmsbackend\Helper;
4
5use Psr\Http\Message\ServerRequestInterface;
6use Psr\Http\Server\RequestHandlerInterface;
7
8/**
9 * @codeCoverageIgnore
10 *
11 */
12class 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}