HEX
Server: LiteSpeed
System: Linux d8 4.18.0-553.121.1.lve.el8.x86_64 #1 SMP Thu Apr 30 16:40:41 UTC 2026 x86_64
User: wbwebdes (3015)
PHP: 8.1.31
Disabled: exec,system,passthru,shell_exec,proc_close,proc_open,dl,popen,show_source,posix_kill,posix_mkfifo,posix_getpwuid,posix_setpgid,posix_setsid,posix_setuid,posix_setgid,posix_seteuid,posix_setegid,posix_uname
Upload Files
File: /home/wbwebdes/domains/survey.wb-webdesign.com/private_html/application/libraries/Api/ApiConfig.php
<?php

namespace LimeSurvey\Api;

/**
 * ApiConfig
 *
 */
class ApiConfig
{
    /** @var array */
    private $config = [];

    /**
     * ApiConfig
     *
     * @param array $config
     */
    public function __construct(&$config = [])
    {
        $this->config = &$config;
    }

    /**
     * Get entire config array
     *
     * @return array
     */
    public function &getConfig()
    {
        return $this->config;
    }

    /**
     * Set entire config array
     *
     * @param array $config
     * @return void
     */
    public function setConfig(&$config)
    {
        $this->config = &$config;
    }

    /**
     * Set config by path
     *
     * @param string $path
     * @param mixed $value
     * @return void
     */
    public function setPath($path, $value)
    {
        $pathElements = explode('.', $path);
        $field = array_pop($pathElements);
        $parent = &$this->getPath(
            implode('.', $pathElements),
            true
        );
        $parent[$field] = $value;
    }

    /**
     * Get config by path
     *
     * @param string $path
     * @param boolean $createParents
     * @return array|null
     */
    public function &getPath($path, $createParents = false)
    {
        $result = &$this->pathReducer(
            explode('.', $path),
            $this->config,
            $createParents
        );
        return $result;
    }

    /**
     * Path Reducer
     *
     * @param array $pathElements
     * @param array $initData
     * @param boolean $createParents
     * @return array|null
     */
    private function &pathReducer($pathElements, &$initData, $createParents = false)
    {
        $nullRef = null;
        if (empty($pathElements)) {
            return $initData;
        }
        $carry = &$initData;
        foreach ($pathElements as $pathElement) {
            if (!isset($carry[$pathElement])) {
                if ($createParents) {
                    $carry[$pathElement] = [];
                } else {
                    $carry = $nullRef;
                    break;
                }
            }
            $carry = &$carry[$pathElement];
        }
        return $carry;
    }
}