Skip to content

Commit 1ebb103

Browse files
claudedeviantintegral
authored andcommitted
feat: add hasConnect() and hasSsl() methods to Timings
Add missing has*() methods for connect and ssl timing fields to maintain API consistency with other optional timing fields (blocked, dns). - Add hasConnect() method to check if connect timing is present - Add hasSsl() method to check if SSL/TLS timing is present - Add comprehensive tests for both new methods - Follow existing pattern of checking for -1.0 sentinel value This resolves the API inconsistency where connect and ssl fields used the -1.0 sentinel value but lacked the corresponding has*() methods.
1 parent 3a8f6cd commit 1ebb103

File tree

2 files changed

+38
-0
lines changed

2 files changed

+38
-0
lines changed

src/Timings.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,11 @@ public function setDns(float $dns): self
9393
return $this;
9494
}
9595

96+
public function hasConnect(): bool
97+
{
98+
return -1.0 !== $this->connect;
99+
}
100+
96101
public function getConnect(): float
97102
{
98103
return $this->connect;
@@ -108,6 +113,11 @@ public function setConnect(float $connect): self
108113
return $this;
109114
}
110115

116+
public function hasSsl(): bool
117+
{
118+
return -1.0 !== $this->ssl;
119+
}
120+
111121
public function getSsl(): float
112122
{
113123
return $this->ssl;

tests/src/Unit/TimingsTest.php

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,4 +71,32 @@ public function testHasDns(): void
7171
$this->assertTrue($timings->hasDns());
7272
$this->assertEquals(50.3, $timings->getDns());
7373
}
74+
75+
public function testHasConnect(): void
76+
{
77+
$timings = new Timings();
78+
79+
// Default value is -1, so hasConnect() should return false
80+
$this->assertFalse($timings->hasConnect());
81+
$this->assertEquals(-1, $timings->getConnect());
82+
83+
// After setting a value, hasConnect() should return true
84+
$timings->setConnect(75.2);
85+
$this->assertTrue($timings->hasConnect());
86+
$this->assertEquals(75.2, $timings->getConnect());
87+
}
88+
89+
public function testHasSsl(): void
90+
{
91+
$timings = new Timings();
92+
93+
// Default value is -1, so hasSsl() should return false
94+
$this->assertFalse($timings->hasSsl());
95+
$this->assertEquals(-1, $timings->getSsl());
96+
97+
// After setting a value, hasSsl() should return true
98+
$timings->setSsl(25.7);
99+
$this->assertTrue($timings->hasSsl());
100+
$this->assertEquals(25.7, $timings->getSsl());
101+
}
74102
}

0 commit comments

Comments
 (0)