summaryrefslogtreecommitdiff
path: root/build/Arr.php
diff options
context:
space:
mode:
authorZhineng Li <[email protected]>2026-02-14 10:08:30 +0800
committerZhineng Li <[email protected]>2026-02-14 10:08:30 +0800
commiteccd5cd5a067f5659982685afdeea209b1888efb (patch)
tree1626c903b854317be1708ce3ccd3b4f4e6e0fc97 /build/Arr.php
downloadacs-metadata-1.0.0+20260212.tar.gz
acs-metadata-1.0.0+20260212.zip
Diffstat (limited to 'build/Arr.php')
-rw-r--r--build/Arr.php26
1 files changed, 26 insertions, 0 deletions
diff --git a/build/Arr.php b/build/Arr.php
new file mode 100644
index 0000000..e9f357d
--- /dev/null
+++ b/build/Arr.php
@@ -0,0 +1,26 @@
+<?php
+
+declare(strict_types=1);
+
+final class Arr
+{
+ /**
+ * Extract the specified keys from the given array.
+ *
+ * @param array<array-key, mixed> $array
+ * @param array<int, array-key> $keys
+ * @return array<array-key, mixed>
+ */
+ public static function only(array $array, array $keys): array
+ {
+ $result = [];
+
+ foreach ($keys as $key) {
+ if (array_key_exists($key, $array)) {
+ $result[$key] = $array[$key];
+ }
+ }
+
+ return $result;
+ }
+}