Code Duplication    Length = 12-12 lines in 2 locations

src/Middleware/Piwik.php 1 location

@@ 98-109 (lines=12) @@
95
     *
96
     * @return ResponseInterface
97
     */
98
    public function __invoke(ServerRequestInterface $request, ResponseInterface $response, callable $next)
99
    {
100
        if (!Middleware::hasAttribute($request, FormatNegotiator::KEY)) {
101
            throw new RuntimeException('The Piwik middleware needs FormatNegotiator executed before');
102
        }
103
104
        if (FormatNegotiator::getFormat($request) === 'html' && !Utils\Helpers::isAjax($request)) {
105
            $response = $this->inject($response, $this->getCode());
106
        }
107
108
        return $next($request, $response);
109
    }
110
111
    /**
112
     * Returns the piwik code.

src/Middleware/GoogleAnalytics.php 1 location

@@ 38-49 (lines=12) @@
35
     *
36
     * @return ResponseInterface
37
     */
38
    public function __invoke(ServerRequestInterface $request, ResponseInterface $response, callable $next)
39
    {
40
        if (!Middleware::hasAttribute($request, FormatNegotiator::KEY)) {
41
            throw new RuntimeException('The GoogleAnalytics middleware needs FormatNegotiator executed before');
42
        }
43
44
        if (FormatNegotiator::getFormat($request) === 'html' && !Utils\Helpers::isAjax($request)) {
45
            $response = $this->inject($response, $this->getCode());
46
        }
47
48
        return $next($request, $response);
49
    }
50
51
    /**
52
     * Returns the google code.