diff --git a/src/ObsAdapter.php b/src/ObsAdapter.php index 98e37ee..2cb237c 100644 --- a/src/ObsAdapter.php +++ b/src/ObsAdapter.php @@ -403,9 +403,15 @@ private function extractExtraMetadata(array $metadata): array $extracted = []; foreach (self::EXTRA_METADATA_FIELDS as $field) { - if (isset($metadata[$field]) && $metadata[$field] !== '') { - $extracted[$field] = $metadata[$field]; + if (! isset($metadata[$field])) { + continue; } + + if ($metadata[$field] === '') { + continue; + } + + $extracted[$field] = $metadata[$field]; } return $extracted; @@ -467,7 +473,7 @@ protected function getObject(string $path): StreamInterface public function listDirObjects(string $dirname = '', bool $recursive = false): array { $prefix = trim($this->pathPrefixer->prefixPath($dirname), '/'); - $prefix = empty($prefix) ? '' : $prefix . '/'; + $prefix = $prefix === '' ? '' : $prefix . '/'; $nextMarker = ''; @@ -511,7 +517,7 @@ public function listDirObjects(string $dirname = '', bool $recursive = false): a private function processObjects(array $result, ?array $objects, string $dirname): array { $result['objects'] = []; - if (! empty($objects)) { + if ($objects !== null && $objects !== []) { foreach ($objects as $object) { $object['Prefix'] = $dirname; $result['objects'][] = $object; @@ -529,7 +535,7 @@ private function processObjects(array $result, ?array $objects, string $dirname) */ private function processPrefixes(array $result, ?array $prefixes): array { - if (! empty($prefixes)) { + if ($prefixes !== null && $prefixes !== []) { foreach ($prefixes as $prefix) { $result['prefix'][] = $prefix['Prefix']; }