Use array_key_exists instead of in_array
This commit is contained in:
parent
0674cf58bf
commit
ce210cd99b
|
@ -93,7 +93,7 @@ abstract class Console extends Command
|
||||||
$arguments = $input->getArguments();
|
$arguments = $input->getArguments();
|
||||||
|
|
||||||
$formats = Database::getInstance()->getMetadataFormats()->getQueryResult();
|
$formats = Database::getInstance()->getMetadataFormats()->getQueryResult();
|
||||||
if (!in_array($arguments['format'], array_keys($formats), true)) {
|
if (!array_key_exists($arguments['format'], $formats)) {
|
||||||
$output->writeln([
|
$output->writeln([
|
||||||
'',
|
'',
|
||||||
sprintf(
|
sprintf(
|
||||||
|
|
|
@ -61,7 +61,7 @@ class UpdateFormatsCommand extends Console
|
||||||
$deleted = 0;
|
$deleted = 0;
|
||||||
$failure = false;
|
$failure = false;
|
||||||
foreach ($formats as $prefix => $format) {
|
foreach ($formats as $prefix => $format) {
|
||||||
if (in_array($prefix, array_keys($inDatabase), true)) {
|
if (array_key_exists($prefix, $inDatabase)) {
|
||||||
if (
|
if (
|
||||||
$format['namespace'] === $inDatabase[$prefix]->getNamespace()
|
$format['namespace'] === $inDatabase[$prefix]->getNamespace()
|
||||||
and $format['schema'] === $inDatabase[$prefix]->getSchema()
|
and $format['schema'] === $inDatabase[$prefix]->getSchema()
|
||||||
|
@ -91,7 +91,7 @@ class UpdateFormatsCommand extends Console
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
foreach (array_keys($inDatabase) as $prefix) {
|
foreach (array_keys($inDatabase) as $prefix) {
|
||||||
if (!in_array($prefix, array_keys($formats), true)) {
|
if (!array_key_exists($prefix, $formats)) {
|
||||||
Database::getInstance()->deleteMetadataFormat($inDatabase[$prefix]);
|
Database::getInstance()->deleteMetadataFormat($inDatabase[$prefix]);
|
||||||
++$deleted;
|
++$deleted;
|
||||||
$output->writeln([
|
$output->writeln([
|
||||||
|
|
|
@ -113,7 +113,7 @@ class ErrorHandler extends AbstractMiddleware
|
||||||
*/
|
*/
|
||||||
public function withError(string $errorCode): ErrorHandler
|
public function withError(string $errorCode): ErrorHandler
|
||||||
{
|
{
|
||||||
if (in_array($errorCode, array_keys(self::OAI_ERRORS), true)) {
|
if (array_key_exists($errorCode, self::OAI_ERRORS)) {
|
||||||
$this->errors[] = $errorCode;
|
$this->errors[] = $errorCode;
|
||||||
} else {
|
} else {
|
||||||
throw new DomainException(
|
throw new DomainException(
|
||||||
|
|
|
@ -72,7 +72,7 @@ class ListIdentifiers extends Middleware
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$prefixes = Database::getInstance()->getMetadataFormats()->getQueryResult();
|
$prefixes = Database::getInstance()->getMetadataFormats()->getQueryResult();
|
||||||
if (!in_array($metadataPrefix, array_keys($prefixes), true)) {
|
if (!array_key_exists($metadataPrefix, $prefixes)) {
|
||||||
ErrorHandler::getInstance()->withError('cannotDisseminateFormat');
|
ErrorHandler::getInstance()->withError('cannotDisseminateFormat');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -84,7 +84,7 @@ class ListIdentifiers extends Middleware
|
||||||
}
|
}
|
||||||
if (isset($set)) {
|
if (isset($set)) {
|
||||||
$sets = Database::getInstance()->getSets()->getQueryResult();
|
$sets = Database::getInstance()->getSets()->getQueryResult();
|
||||||
if (!in_array($set, array_keys($sets), true)) {
|
if (!array_key_exists($set, $sets)) {
|
||||||
ErrorHandler::getInstance()->withError('noSetHierarchy');
|
ErrorHandler::getInstance()->withError('noSetHierarchy');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue