Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@
},
"scripts": {
"fixture:download": [
"curl -o ./tests/Fixtures/vulnerabilities.production.json https://www.wordfence.com/api/intelligence/v2/vulnerabilities/production",
"curl -o ./tests/Fixtures/vulnerabilities.scanner.json https://www.wordfence.com/api/intelligence/v2/vulnerabilities/scanner"
"curl -o ./tests/Fixtures/vulnerabilities.Production.json https://www.wordfence.com/api/intelligence/v2/vulnerabilities/production",
"curl -o ./tests/Fixtures/vulnerabilities.Scanner.json https://www.wordfence.com/api/intelligence/v2/vulnerabilities/scanner"
],
"lint": [
"@composer normalize --dry-run",
Expand Down
5 changes: 1 addition & 4 deletions src/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,7 @@ public function fetch(Feed $feed): Generator
private function get(Feed $feed): ResponseInterface
{
try {
return $this->http->request(
'GET',
$feed->url(),
);
return $this->http->request('GET', $feed->value);
Copy link

Copilot AI Oct 26, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] The HTTP method is now explicitly specified as 'GET' instead of using the dedicated get() method. While functionally equivalent, using $this->http->get($feed->value) would be more idiomatic and clearer in intent. The get() method is the standard Guzzle approach for GET requests.

Suggested change
return $this->http->request('GET', $feed->value);
return $this->http->get($feed->value);

Copilot uses AI. Check for mistakes.
} catch (TransferException $exception) {
// Guzzle throws exceptions for non-2xx responses.
throw HttpException::fromResponse($feed, $exception);
Expand Down
2 changes: 1 addition & 1 deletion src/Exceptions/HttpException.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public static function fromResponse(Feed $feed, TransferException $original): se
{
$message = sprintf(
'Unable to fetch from Wordfence %s feed. %s',
$feed->label(),
$feed->name,
$original->getMessage(),
);

Expand Down
2 changes: 1 addition & 1 deletion src/Exceptions/InvalidJsonException.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public static function forFeedResponse(Feed $feed): self
return new self(
sprintf(
'Unable to parse Wordfence %s feed response: invalid JSON',
$feed->label(),
$feed->name,
),
);
}
Expand Down
22 changes: 3 additions & 19 deletions src/Feed.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,8 @@

namespace TypistTech\WordfenceApi;

enum Feed
enum Feed: string
{
case Production;
case Scanner;

public function label(): string // TODO!
{
return match ($this) {
self::Production => 'production',
self::Scanner => 'scanner',
};
}

public function url(): string
{
return match ($this) {
self::Production => 'https://www.wordfence.com/api/intelligence/v2/vulnerabilities/production',
self::Scanner => 'https://www.wordfence.com/api/intelligence/v2/vulnerabilities/scanner',
};
}
case Production = 'https://www.wordfence.com/api/intelligence/v2/vulnerabilities/production';
case Scanner = 'https://www.wordfence.com/api/intelligence/v2/vulnerabilities/scanner';
}
Loading