Browse Source

code sniffer fixes

d9_islandora
elizoller 4 years ago
parent
commit
51cd810cca
  1. 14
      src/Flysystem/Adapter/FedoraAdapter.php
  2. 2
      src/GeminiLookup.php
  3. 3
      tests/src/Functional/EmitNodeEventTest.php
  4. 7
      tests/src/Kernel/FedoraAdapterTest.php

14
src/Flysystem/Adapter/FedoraAdapter.php

@ -143,12 +143,14 @@ class FedoraAdapter implements AdapterInterface {
// NonRDFSource's are considered files. Everything else is a
// directory.
$type = 'dir';
// phpcs:disable
if (class_exists(\GuzzleHttp\Psr7\Header::class)) {
$links = \GuzzleHttp\Psr7\Header::parse($response->getHeader('Link'));
}
else {
$links = \GuzzleHttp\Psr7\parse_header($response->getHeader('Link'));
}
$links = \GuzzleHttp\Psr7\Header::parse($response->getHeader('Link'));
}
else {
$links = \GuzzleHttp\Psr7\parse_header($response->getHeader('Link'));
}
// phpcs:enable
foreach ($links as $link) {
if ($link['rel'] == 'type' && $link[0] == '<http://www.w3.org/ns/ldp#NonRDFSource>') {
$type = 'file';
@ -381,12 +383,14 @@ class FedoraAdapter implements AdapterInterface {
$return = NULL;
if ($response->getStatusCode() == 410) {
$return = FALSE;
// phpcs:disable
if (class_exists(\GuzzleHttp\Psr7\Header::class)) {
$link_headers = \GuzzleHttp\Psr7\Header::parse($response->getHeader('Link'));
}
else {
$link_headers = \GuzzleHttp\Psr7\parse_header($response->getHeader('Link'));
}
// phpcs:enable
if ($link_headers) {
$tombstones = array_filter($link_headers, function ($o) {
return (isset($o['rel']) && $o['rel'] == 'hasTombstone');

2
src/GeminiLookup.php

@ -135,12 +135,14 @@ class GeminiLookup {
$urls['fedora'],
['allow_redirects' => FALSE, 'headers' => ['Authorization' => $token]]
);
// phpcs:disable
if (class_exists(\GuzzleHttp\Psr7\Header::class)) {
$links = \GuzzleHttp\Psr7\Header::parse($head->getHeader('Link'));
}
else {
$links = \GuzzleHttp\Psr7\parse_header($head->getHeader('Link'));
}
//phpcs:enable
foreach ($links as $link) {
if ($link['rel'] == 'describedby') {
return trim($link[0], '<>');

3
tests/src/Functional/EmitNodeEventTest.php

@ -102,8 +102,7 @@ class EmitNodeEventTest extends IslandoraFunctionalTestBase {
"Authorization header must be set"
);
$matches = [];
$this->assertTrue((boolean)
preg_match('/^Bearer(\s*.*)/', $headers['Authorization'], $matches),
$this->assertTrue((boolean) preg_match('/^Bearer(\s*.*)/', $headers['Authorization'], $matches),
"Authorization header must be a bearer token"
);
$this->assertTrue(

7
tests/src/Kernel/FedoraAdapterTest.php

@ -51,12 +51,14 @@ class FedoraAdapterTest extends IslandoraKernelTestBase {
]);
$prophecy->getHeader('Content-Type')->willReturn(['text/plain']);
$prophecy->getHeader('Content-Length')->willReturn([strlen("DERP")]);
// phpcs:disable
if (class_exists(\GuzzleHttp\Psr7\Utils::class)) {
$prophecy->getBody()->willReturn(\GuzzleHttp\Psr7\Utils::streamFor("DERP"));
}
else {
$prophecy->getBody()->willReturn(\GuzzleHttp\Psr7\stream_for("DERP"));
}
// phpcs:enable
$response = $prophecy->reveal();
$prophecy = $this->prophesize(IFedoraApi::class);
@ -122,13 +124,14 @@ class FedoraAdapterTest extends IslandoraKernelTestBase {
]);
$prophecy->getHeader('Content-Type')->willReturn(['text/plain']);
$prophecy->getHeader('Content-Length')->willReturn([strlen("DERP")]);
// phpcs:disable
if (class_exists(\GuzzleHttp\Psr7\Utils::class)) {
$prophecy->getBody()->willReturn(\GuzzleHttp\Psr7\Utils::streamFor("DERP"));
}
else {
$prophecy->getBody()->willReturn(\GuzzleHttp\Psr7\stream_for("DERP"));
}
// phpcs:enable
$fedora_prophecy->getResourceHeaders('')->willReturn($prophecy->reveal());
$api = $fedora_prophecy->reveal();
@ -619,12 +622,14 @@ class FedoraAdapterTest extends IslandoraKernelTestBase {
]);
$prophecy->getHeader('Content-Type')->willReturn(['text/plain']);
$prophecy->getHeader('Content-Length')->willReturn([strlen("DERP")]);
// phpcs:disable
if (class_exists(\GuzzleHttp\Psr7\Utils::class)) {
$prophecy->getBody()->willReturn(\GuzzleHttp\Psr7\Utils::streamFor("DERP"));
}
else {
$prophecy->getBody()->willReturn(\GuzzleHttp\Psr7\stream_for("DERP"));
}
// phpcs:enable
$response = $prophecy->reveal();
$fedora_prophecy = $this->prophesize(IFedoraApi::class);

Loading…
Cancel
Save