Skip to content

Commit a264cd5

Browse files
authored
Remove Feed::label() and Feed::url() (#30)
1 parent 24fb8ca commit a264cd5

File tree

8 files changed

+9
-28
lines changed

8 files changed

+9
-28
lines changed

composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,8 @@
6060
},
6161
"scripts": {
6262
"fixture:download": [
63-
"curl -o ./tests/Fixtures/vulnerabilities.production.json https://www.wordfence.com/api/intelligence/v2/vulnerabilities/production",
64-
"curl -o ./tests/Fixtures/vulnerabilities.scanner.json https://www.wordfence.com/api/intelligence/v2/vulnerabilities/scanner"
63+
"curl -o ./tests/Fixtures/vulnerabilities.Production.json https://www.wordfence.com/api/intelligence/v2/vulnerabilities/production",
64+
"curl -o ./tests/Fixtures/vulnerabilities.Scanner.json https://www.wordfence.com/api/intelligence/v2/vulnerabilities/scanner"
6565
],
6666
"lint": [
6767
"@composer normalize --dry-run",

src/Client.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,7 @@ public function fetch(Feed $feed): Generator
4949
private function get(Feed $feed): ResponseInterface
5050
{
5151
try {
52-
return $this->http->request(
53-
'GET',
54-
$feed->url(),
55-
);
52+
return $this->http->request('GET', $feed->value);
5653
} catch (TransferException $exception) {
5754
// Guzzle throws exceptions for non-2xx responses.
5855
throw HttpException::fromResponse($feed, $exception);

src/Exceptions/HttpException.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ public static function fromResponse(Feed $feed, TransferException $original): se
1414
{
1515
$message = sprintf(
1616
'Unable to fetch from Wordfence %s feed. %s',
17-
$feed->label(),
17+
$feed->name,
1818
$original->getMessage(),
1919
);
2020

src/Exceptions/InvalidJsonException.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ public static function forFeedResponse(Feed $feed): self
1414
return new self(
1515
sprintf(
1616
'Unable to parse Wordfence %s feed response: invalid JSON',
17-
$feed->label(),
17+
$feed->name,
1818
),
1919
);
2020
}

src/Feed.php

Lines changed: 3 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4,24 +4,8 @@
44

55
namespace TypistTech\WordfenceApi;
66

7-
enum Feed
7+
enum Feed: string
88
{
9-
case Production;
10-
case Scanner;
11-
12-
public function label(): string // TODO!
13-
{
14-
return match ($this) {
15-
self::Production => 'production',
16-
self::Scanner => 'scanner',
17-
};
18-
}
19-
20-
public function url(): string
21-
{
22-
return match ($this) {
23-
self::Production => 'https://www.wordfence.com/api/intelligence/v2/vulnerabilities/production',
24-
self::Scanner => 'https://www.wordfence.com/api/intelligence/v2/vulnerabilities/scanner',
25-
};
26-
}
9+
case Production = 'https://www.wordfence.com/api/intelligence/v2/vulnerabilities/production';
10+
case Scanner = 'https://www.wordfence.com/api/intelligence/v2/vulnerabilities/scanner';
2711
}

tests/Feature/TestCase.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ abstract class TestCase extends BaseTestCase
1515
{
1616
public function mockHttpClient(Feed $feed): Http
1717
{
18-
$path = fixture('vulnerabilities.'.$feed->label().'.json'); // TODO!
18+
$path = fixture("vulnerabilities.{$feed->name}.json");
1919
$body = file_get_contents($path);
2020

2121
$mock = new MockHandler([

0 commit comments

Comments
 (0)