public static function create($data = NULL) { if ($data instanceof \stdClass) { $data = (array) $data; } if (!is_array($data)) { throw new \Exception("Creating a connection needs a data structure, array or stdClass"); } $missing = \apf\validate\Vector::mustHaveKeys(["id", "host", "port", "schemas", "user", "pass", "driver"], $data, $throw = FALSE); if (is_string($missing)) { throw new \Exception("Missing {$missing} parameter, when attempting to create connection structure"); } if (empty($data["id"])) { throw new \Exception("Must provide a unique identifier (id) for this connection"); } $user = new \apf\type\User($data["user"], $data["pass"]); $host = new \apf\net\Host($data["host"]); $class = __CLASS__; return new $class($host, $data["port"], $user, $data["id"], $data["schemas"], $data["driver"]); }