Skip to content

Commit

Permalink
add function to get all tables from Server
Browse files Browse the repository at this point in the history
  • Loading branch information
Scott Sandler committed Aug 17, 2020
1 parent 8a1a34a commit 99951da
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/Server.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace Slack\SQLFake;

use namespace HH\Lib\C;
use namespace HH\Lib\{C, Dict};

final class Server {

Expand All @@ -15,6 +15,12 @@ public static function getAll(): dict<string, this> {
return static::$instances;
}

public static function getAllTables(): dict<string, dict<string, dict<string, vec<dict<string, mixed>>>>> {
return Dict\map(static::getAll(), ($server) ==> {
return $server->databases;
});
}

/**
* This will override everything in $instances
*/
Expand Down Expand Up @@ -42,7 +48,7 @@ public static function getOrCreate(string $name): this {
public static function cloneByName(string $name, string $clone_name): this {
$clone = static::get($clone_name);
if ($clone === null) {
throw new SQLFakeRuntimeException("Server $clone_name not found, unable to clone databases and snapshots");
throw new SQLFakeRuntimeException("Server $clone_name not found, unable to clone databases and snapshots");
}

$server = static::getOrCreate($name);
Expand Down

0 comments on commit 99951da

Please sign in to comment.