HEX
Server: Apache/2.4.34 (Red Hat) OpenSSL/1.0.2k-fips
System: Linux WORDPRESS 3.10.0-1160.118.1.el7.x86_64 #1 SMP Thu Apr 4 03:33:23 EDT 2024 x86_64
User: digital (1020)
PHP: 7.2.24
Disabled: NONE
Upload Files
File: /datos/www/fabricas.colombiatrade.com.co/vendor2/consolidation/config/src/Util/ConfigGroup.php
<?php
namespace Consolidation\Config\Util;

/**
 * Fetch a configuration value from a configuration group. If the
 * desired configuration value is not found in the most specific
 * group named, keep stepping up to the next parent group until a
 * value is located.
 *
 * Given the following constructor inputs:
 *   - $prefix  = "command."
 *   - $group   = "foo.bar.baz"
 *   - $postfix = ".options."
 * Then the `get` method will then consider, in order:
 *   - command.foo.bar.baz.options
 *   - command.foo.bar.options
 *   - command.foo.options
 * If any of these contain an option for "$key", then return its value.
 */
abstract class ConfigGroup
{
    protected $config;
    protected $group;
    protected $prefix;
    protected $postfix;

    public function __construct($config, $group, $prefix = '', $postfix = '.')
    {
        $this->config = $config;
        $this->group = $group;
        $this->prefix = $prefix;
        $this->postfix = $postfix;
    }

    /**
     * Return a description of the configuration group (with prefix and postfix).
     */
    public function describe($property)
    {
        return $this->prefix . $this->group . $this->postfix . $property;
    }

    /**
     * Get the requested configuration key from the most specific configuration
     * group that contains it.
     */
    abstract public function get($key);

    /**
     * Given a group name, such as "foo.bar.baz", return the next configuration
     * group in the fallback hierarchy, e.g. "foo.bar".
     */
    protected function moreGeneralGroupName($group)
    {
        $result = preg_replace('#\.[^.]*$#', '', $group);
        if ($result != $group) {
            return $result;
        }
        return false;
    }
}