<commit_before><?php

declare(strict_types=1);

namespace SimpleSAML\Metadata\Sources;

use Exception;
use RobRichards\XMLSecLibs\XMLSecurityDSig;
use SimpleSAML\Assert\Assert;
use SimpleSAML\Configuration;
use SimpleSAML\Error;
use SimpleSAML\Logger;
use SimpleSAML\Metadata\MetaDataStorageSource;
use SimpleSAML\Metadata\SAMLParser;
use SimpleSAML\Utils;
use Symfony\Component\HttpFoundation\File\File;

use function array_key_exists;
use function error_get_last;
use function is_array;
use function serialize;
use function sha1;
use function sprintf;
use function strval;
use function time;
use function unserialize;
use function urlencode;

/**
 * This class implements SAML Metadata Query Protocol
 *
 * @package simplesamlphp/simplesamlphp
 */

class MDQ extends MetaDataStorageSource
{
    /**
     * The URL of MDQ server (url:port)
     *
     * @var string
     */
    private string $server;

    /**
     * The cache directory, or null if no cache directory is configured.
     *
     * @var string|null
     */
    private ?string $cacheDir;

    /**
     * The maximum cache length, in seconds.
     *
     * @var integer
     */
    private int $cacheLength;

    /**
     * This function initializes the dynamic XML metadata source.
     *
     * Options:
     * - 'server': URL of the MDQ server (url:port). Mandatory.
     *
     * Optional.
     * - 'cachedir':  Directory where metadata can be cached. Optional.
     * - 'cachelength': Maximum time metadata cah be cached, in seconds. Default to 24
     *                  hours (86400 seconds).
     *
     * @param array $config The configuration for this instance of the XML metadata source.
     *
     * @throws \Exception If no server option can be found in the configuration.
     */
    protected function __construct(array $config)
    {
        parent::__construct($config);

        if (!array_key_exists('server', $config)) {
            throw new Exception(__CLASS__ . ": the 'server' configuration option is not set.");
        } else {
            $this->server = $config['server'];
        }

        if (array_key_exists('cachedir', $config)) {
            $globalConfig = Configuration::getInstance();
            $this->cacheDir = $globalConfig->resolvePath($config['cachedir']);
        } else {
            $this->cacheDir = null;
        }

        if (array_key_exists('cachelength', $config)) {
            $this->cacheLength = $config['cachelength'];
        } else {
            $this->cacheLength = 86400;
        }
    }


    /**
     * This function is not implemented.
     *
     * @param string $set The set we want to list metadata for.
     *
     * @return array An empty array.
     */
    public function getMetadataSet(string $set): array
    {<commit_msg>Psalm: fix TooManyArguments<commit_after><?php

declare(strict_types=1);

namespace SimpleSAML\Metadata\Sources;

use Exception;
use RobRichards\XMLSecLibs\XMLSecurityDSig;
use SimpleSAML\Assert\Assert;
use SimpleSAML\Configuration;
use SimpleSAML\Error;
use SimpleSAML\Logger;
use SimpleSAML\Metadata\MetaDataStorageSource;
use SimpleSAML\Metadata\SAMLParser;
use SimpleSAML\Utils;
use Symfony\Component\HttpFoundation\File\File;

use function array_key_exists;
use function error_get_last;
use function is_array;
use function serialize;
use function sha1;
use function sprintf;
use function strval;
use function time;
use function unserialize;
use function urlencode;

/**
 * This class implements SAML Metadata Query Protocol
 *
 * @package simplesamlphp/simplesamlphp
 */

class MDQ extends MetaDataStorageSource
{
    /**
     * The URL of MDQ server (url:port)
     *
     * @var string
     */
    private string $server;

    /**
     * The cache directory, or null if no cache directory is configured.
     *
     * @var string|null
     */
    private ?string $cacheDir;

    /**
     * The maximum cache length, in seconds.
     *
     * @var integer
     */
    private int $cacheLength;

    /**
     * This function initializes the dynamic XML metadata source.
     *
     * Options:
     * - 'server': URL of the MDQ server (url:port). Mandatory.
     *
     * Optional.
     * - 'cachedir':  Directory where metadata can be cached. Optional.
     * - 'cachelength': Maximum time metadata cah be cached, in seconds. Default to 24
     *                  hours (86400 seconds).
     *
     * @param array $config The configuration for this instance of the XML metadata source.
     *
     * @throws \Exception If no server option can be found in the configuration.
     */
    protected function __construct(array $config)
    {
        parent::__construct();

        if (!array_key_exists('server', $config)) {
            throw new Exception(__CLASS__ . ": the 'server' configuration option is not set.");
        } else {
            $this->server = $config['server'];
        }

        if (array_key_exists('cachedir', $config)) {
            $globalConfig = Configuration::getInstance();
            $this->cacheDir = $globalConfig->resolvePath($config['cachedir']);
        } else {
            $this->cacheDir = null;
        }

        if (array_key_exists('cachelength', $config)) {
            $this->cacheLength = $config['cachelength'];
        } else {
            $this->cacheLength = 86400;
        }
    }


    /**
     * This function is not implemented.
     *
     * @param string $set The set we want to list metadata for.
     *
     * @return array An empty array.
     */
    public function getMetadataSet(string $set): array
    {
{'fraction_non_alphanumeric': 0.10222141954126783, 'fraction_numerical': 0.0050568900126422255, 'mean_word_length': 2.5705996131528046, 'pattern_counts': {'":': 2, '<': 5, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5537360', 'n_tokens_mistral': 1592, 'n_tokens_neox': 1536, 'n_words': 474}