From a2df9a69dcc14cb70118cda2ded499055e7ee358 Mon Sep 17 00:00:00 2001 From: Minteck Date: Sun, 21 Aug 2022 17:31:56 +0200 Subject: m. update --- includes/bitset.php | 73 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 73 insertions(+) create mode 100644 includes/bitset.php (limited to 'includes/bitset.php') diff --git a/includes/bitset.php b/includes/bitset.php new file mode 100644 index 0000000..272325a --- /dev/null +++ b/includes/bitset.php @@ -0,0 +1,73 @@ + "earth", + "0010" => "unicorn", + "0011" => "pegasus", + "0100" => "alicorn", + "0101" => "batpony", + "0110" => "crystal", + default => null, + }; + + $species2 = match ($species2) { + "0001" => "earth", + "0010" => "unicorn", + "0011" => "pegasus", + "0100" => "alicorn", + "0101" => "batpony", + "0110" => "crystal", + default => null, + }; + + return [ + 'shared_memory' => $sharedMemory, + 'median' => $median, + 'protector' => $protector, + 'fictive' => $fictive, + 'little' => $little, + 'not_talking' => $notTalking, + 'host' => $host, + 'robot' => $robot, + 'species' => array_filter([ + $species1, + $species2 + ], function ($i) { + return isset($i); + }) + ]; +} + +function parseMetadata ($metadata) { + if (isset($metadata)) { + if ($metadata["bitset"]) { + $m = parseBitset($metadata["bitset"]); + $m["marefriends"] = $metadata["marefriends"] ?? []; + $m["bitset"] = $metadata["bitset"] ?? []; + $m["sisters"] = $metadata["sisters"] ?? []; + $m["regression"] = $metadata["regression"] ?? null; + $m["caretakers"] = $metadata["caretakers"] ?? []; + $m["median"] = $metadata["median"] ?? null; + } else { + $m = $metadata; + } + + return $m; + } else { + return $metadata; + } +} \ No newline at end of file -- cgit