Trianglman\Sqrl\SqrlConfiguration::loadConfigFromJSON PHP Method

loadConfigFromJSON() protected method

protected loadConfigFromJSON ( $filePath )
    protected function loadConfigFromJSON($filePath)
    {
        if (!file_exists($filePath)) {
            throw new \InvalidArgumentException('Configuration file not found');
        }
        $data = file_get_contents($filePath);
        $decoded = json_decode($data);
        if (is_null($decoded)) {
            throw new \InvalidArgumentException('Configuration data could not be parsed. Is it JSON formatted?');
        }
        if (is_array($decoded->accepted_versions)) {
            $this->setAcceptedVersions($decoded->accepted_versions);
        }
        $this->setSecure(!empty($decoded->secure) && (int) $decoded->secure > 0);
        $this->setDomain(!empty($decoded->key_domain) ? $decoded->key_domain : '');
        $this->setAuthenticationPath(!empty($decoded->authentication_path) ? $decoded->authentication_path : '');
        $this->setFriendlyName(!empty($decoded->friendly_name) ? $decoded->friendly_name : '');
        $this->setAnonAllowed(!empty($decoded->allow_anonymous_accounts) && (int) $decoded->allow_anonymous_accounts > 0);
        if (!empty($decoded->nonce_max_age)) {
            $this->setNonceMaxAge($decoded->nonce_max_age);
        }
        if (!empty($decoded->height)) {
            $this->setQrHeight($decoded->height);
        }
        if (!empty($decoded->padding)) {
            $this->setQrPadding($decoded->padding);
        }
        $this->setNonceSalt(!empty($decoded->nonce_salt) ? $decoded->nonce_salt : '');
    }