Skip to content

Commit ae76ab2

Browse files
committed
fix: Adjustments based on code review
- Change stripos to strpos to match case-insensitive - Rename $mediaTypeBlacklist to $allowedInvalidContentTypeEndpoints - Refactor for to foreach
1 parent a72e0d4 commit ae76ab2

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

src/JsonSchema/Uri/UriRetriever.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,9 @@ class UriRetriever implements BaseUriRetrieverInterface
3333
);
3434

3535
/**
36-
* @var array A blacklist for media type check exclusion
36+
* @var array A list of endpoints for media type check exclusion
3737
*/
38-
protected $mediaTypeBlacklist = array(
38+
protected $allowedInvalidContentTypeEndpoints = array(
3939
'http://json-schema.org/',
4040
'https://json-schema.org/'
4141
);
@@ -53,13 +53,13 @@ class UriRetriever implements BaseUriRetrieverInterface
5353
private $schemaCache = array();
5454

5555
/**
56-
* Adds an endpoint to the media type validation blacklist
56+
* Adds an endpoint to the media type validation exclusion list
5757
*
5858
* @param string $endpoint
5959
*/
60-
public function addBlacklistedEndpoint($endpoint)
60+
public function addInvalidContentTypeEndpoint($endpoint)
6161
{
62-
$this->mediaTypeBlacklist[] = $endpoint;
62+
$this->allowedInvalidContentTypeEndpoints[] = $endpoint;
6363
}
6464

6565
/**
@@ -83,8 +83,8 @@ public function confirmMediaType($uriRetriever, $uri)
8383
return;
8484
}
8585

86-
for ($i = 0, $iMax = count($this->mediaTypeBlacklist); $i < $iMax; $i++) {
87-
if (stripos($uri, $this->mediaTypeBlacklist[$i]) === 0) {
86+
foreach ($this->allowedInvalidContentTypeEndpoints as $endpoint) {
87+
if (strpos($uri, $endpoint) === 0) {
8888
return true;
8989
}
9090
}

tests/Uri/UriRetrieverTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,7 @@ public function testJsonSchemaOrgMediaTypeBlacklistAdded()
356356
$mock = $this->getMock('JsonSchema\Uri\UriRetriever', array('getContentType'));
357357
$mock->method('getContentType')->willReturn('Application/X-Fake-Type');
358358
$retriever = new UriRetriever();
359-
$retriever->addBlacklistedEndpoint('http://example.com');
359+
$retriever->addInvalidContentTypeEndpoint('http://example.com');
360360

361361
$retriever->confirmMediaType($mock, 'http://example.com');
362362
}

0 commit comments

Comments
 (0)