Skip to content

Commit 4ef8579

Browse files
andreea-anamariaandreea_cojocaru
andauthored
Made small code improvements after update to php v8.1 (#18)
Co-authored-by: andreea_cojocaru <andreea.cojocaru@emag.ro>
1 parent c2a7d19 commit 4ef8579

File tree

3 files changed

+6
-8
lines changed

3 files changed

+6
-8
lines changed

src/GuzzleMiddleware/HttpCodeProfiler.php

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ class HttpCodeProfiler
1515
/** @var StatsDataInterface */
1616
private $statsdService;
1717

18-
/** @var string */
19-
private $statsdKey;
18+
/** @var string|null */
19+
private $statsdKey = null;
2020

2121
public function __construct(StatsDataInterface $statsdService)
2222
{
@@ -54,9 +54,8 @@ private function startProfiling(TransferStats $stats): void
5454
private function getKey(TransferStats $stats): string
5555
{
5656
$key = ($this->statsdKey ?? $this->generateKey($stats));
57-
$statusCode = (!empty($stats->getResponse())) ? $stats->getResponse()->getStatusCode() : '';
58-
$key .= '.' . $statusCode;
57+
$statusCode = (empty($stats->getResponse())) ? '' : $stats->getResponse()->getStatusCode();
5958

60-
return $key;
59+
return $key . ('.' . $statusCode);
6160
}
6261
}

src/GuzzleMiddleware/TimingProfiler.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ class TimingProfiler
1414
/** @var StatsDataInterface */
1515
private $statsdService;
1616

17-
/** @var string */
18-
private $statsdKey;
17+
/** @var string|null */
18+
private $statsdKey = null;
1919

2020
public function __construct(StatsDataInterface $statsdService)
2121
{

src/Tests/TimingProfilerTest.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
<?php
22
namespace EmagTechLabs\Tests;
33

4-
54
use EmagTechLabs\GuzzleMiddleware\Adapter\StatsDataInterface;
65
use GuzzleHttp\Client;
76
use GuzzleHttp\HandlerStack;

0 commit comments

Comments
 (0)