Skip to content

Add Decoder::getTXTRecordFromDomain()#40

Merged
mlocati merged 3 commits intomlocati:mainfrom
BrandonXLF:main
Jun 23, 2025
Merged

Add Decoder::getTXTRecordFromDomain()#40
mlocati merged 3 commits intomlocati:mainfrom
BrandonXLF:main

Conversation

@BrandonXLF
Copy link
Copy Markdown
Contributor

This PR moves SPF TXT record finding functionality to its function, getTXTRecordFromDomain.

For my project, I would like to have access to the raw DNS text record to show to users whenever possible. Currently, this is not possible since TXT record finding happens within getRecordFromDomain, so it's impossible to access the raw TXT record outside of that function.

With the PR, the following is possible:

$decoder = new \SPFLib\Decoder();
$rawRecord = null;

try {
	$rawRecord = $decoder->getTXTRecordFromDomain("example.com");
} catch ( \Exception $e ) {
	// Handle raw TXT record-related error.
}

$record = null;

if ($rawRecord) {
	try {
		$record = $decoder->getRecordFromTXT($rawRecord);
	} catch ( \Exception $e ) {
		// Handle recording parsing-related error.
		// Has access to $rawRecord to provide further context.
	}
}

// Has access to both $rawRecord and $record.

@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Jun 22, 2025

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 92.76%. Comparing base (7312918) to head (4da1fd5).
Report is 1 commits behind head on main.

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@             Coverage Diff              @@
##               main      #40      +/-   ##
============================================
+ Coverage     92.74%   92.76%   +0.02%     
- Complexity      662      664       +2     
============================================
  Files            44       44              
  Lines          1598     1603       +5     
============================================
+ Hits           1482     1487       +5     
  Misses          116      116              
Flag Coverage Δ
unittests 92.76% <100.00%> (+0.02%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@mlocati
Copy link
Copy Markdown
Owner

mlocati commented Jun 23, 2025

@BrandonXLF I've updated this PR with 4da1fd5

@mlocati mlocati changed the title Move TXT record finding to its own function Add Decoder::getTXTRecordFromDomain() Jun 23, 2025
@mlocati mlocati merged commit 21afb42 into mlocati:main Jun 23, 2025
16 checks passed
@mlocati
Copy link
Copy Markdown
Owner

mlocati commented Jun 23, 2025

Thanks! I've just published version 3.3.0 with this change.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants