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();
|
||||
|
||||
$formats = Database::getInstance()->getMetadataFormats()->getQueryResult();
|
||||
if (!in_array($arguments['format'], array_keys($formats), true)) {
|
||||
if (!array_key_exists($arguments['format'], $formats)) {
|
||||
$output->writeln([
|
||||
'',
|
||||
sprintf(
|
||||
|
|
|
@ -61,7 +61,7 @@ class UpdateFormatsCommand extends Console
|
|||
$deleted = 0;
|
||||
$failure = false;
|
||||
foreach ($formats as $prefix => $format) {
|
||||
if (in_array($prefix, array_keys($inDatabase), true)) {
|
||||
if (array_key_exists($prefix, $inDatabase)) {
|
||||
if (
|
||||
$format['namespace'] === $inDatabase[$prefix]->getNamespace()
|
||||
and $format['schema'] === $inDatabase[$prefix]->getSchema()
|
||||
|
@ -91,7 +91,7 @@ class UpdateFormatsCommand extends Console
|
|||
}
|
||||
}
|
||||
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]);
|
||||
++$deleted;
|
||||
$output->writeln([
|
||||
|
|
|
@ -113,7 +113,7 @@ class ErrorHandler extends AbstractMiddleware
|
|||
*/
|
||||
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;
|
||||
} else {
|
||||
throw new DomainException(
|
||||
|
|
|
@ -72,7 +72,7 @@ class ListIdentifiers extends Middleware
|
|||
}
|
||||
}
|
||||
$prefixes = Database::getInstance()->getMetadataFormats()->getQueryResult();
|
||||
if (!in_array($metadataPrefix, array_keys($prefixes), true)) {
|
||||
if (!array_key_exists($metadataPrefix, $prefixes)) {
|
||||
ErrorHandler::getInstance()->withError('cannotDisseminateFormat');
|
||||
return;
|
||||
}
|
||||
|
@ -84,7 +84,7 @@ class ListIdentifiers extends Middleware
|
|||
}
|
||||
if (isset($set)) {
|
||||
$sets = Database::getInstance()->getSets()->getQueryResult();
|
||||
if (!in_array($set, array_keys($sets), true)) {
|
||||
if (!array_key_exists($set, $sets)) {
|
||||
ErrorHandler::getInstance()->withError('noSetHierarchy');
|
||||
return;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue