public function connect($namespace = '', $level = 3) {


        // Connect to the host using the specified namespace
        if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
            $connection = $this->com->ConnectServer($this->getHost(), $namespace, $this->getDomain() . $this->getUsername(), $this->password);
        } else {
            $namespacePrepared = escapeshellarg($namespace);
            $connection = "wmic -U " . $this->getDomain() . $this->getUsername() . " --password=" . $this->password . " //" . $this->getHost() . " --namespace=" . $namespacePrepared . " ";
        }

        if ($connection) {
            if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
                // Set the impersonation level
                $connection->Security_->ImpersonationLevel = (int) $level;
            }

            // Set the connection
            $this->setConnection(new Connection($connection));

            return $this->connection;
        }

        return false;
    }