NewRelicMiddleware::getTransactionName()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 12

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 12
rs 9.8666
c 0
b 0
f 0
cc 2
nc 2
nop 1
1
<?php
2
3
namespace Digia\Lumen\ContentfulSync\Http\Middleware;
4
5
use Illuminate\Http\Request;
6
use Nord\Lumen\NewRelic\NewRelicMiddleware as BaseNewRelicMiddleware;
7
8
/**
9
 * Class NewRelicMiddleware
10
 * @package Digia\Lumen\ContentfulSync\Http\Middleware
11
 */
12
class NewRelicMiddleware extends BaseNewRelicMiddleware
13
{
14
15
    /**
16
     * Attribute parameters that the controller supplies in the request
17
     */
18
    public const ATTRIBUTE_TOPIC        = __CLASS__ . '_topic';
19
    public const ATTRIBUTE_CONTENT_TYPE = __CLASS__ . '_content';
20
21
    /**
22
     * @inheritDoc
23
     */
24
    public function getTransactionName(Request $request): string
25
    {
26
        // Extract some attributes from the request
27
        $topic       = $request->attributes->get(self::ATTRIBUTE_TOPIC);
28
        $contentType = $request->attributes->get(self::ATTRIBUTE_CONTENT_TYPE);
29
30
        if ($contentType !== null) {
31
            return "{$topic}@{$contentType}";
32
        }
33
34
        return $topic;
35
    }
36
37
}
38