public function get(string $configKey, string $configFile = 'default', ?string $parseType = null)
    {
        $this->load($configFile);
        // check if configs for this file is loaded
        if (!isset($this->data[$configFile])) {
            return false;
        }

        // check if config key is exist
        if (!isset($this->data[$configFile][$configKey])) {
            return false;
        }

        $response = $this->data[$configFile][$configKey];

        // try to convert config value by defined parse type
        $parseType = Str::lowerCase($parseType);
        switch ($parseType) {
            case 'int':
            case 'integer':
                $response = (int)$response;
                break;
            case 'bool':
            case 'boolean':
                $response = (bool)$response;
                break;
            case 'float':
                $response = (float)$response;
                break;
            case 'double':
                $response = (double)$response;
                break;
        }

        return $response;
    }
public function get(string $configKey, string $configFile = 'default', ?string $parseType = null)
    {
        $this->load($configFile);
        // check if configs for this file is loaded
        if (!isset($this->data[$configFile])) {
            return false;
        }

        // check if config key is exist
        if (!isset($this->data[$configFile][$configKey])) {
            return false;
        }

        $response = $this->data[$configFile][$configKey];

        // try to convert config value by defined parse type
        $parseType = Str::lowerCase($parseType);
        switch ($parseType) {
            case 'int':
            case 'integer':
                $response = (int)$response;
                break;
            case 'bool':
            case 'boolean':
                $response = (bool)$response;
                break;
            case 'float':
                $response = (float)$response;
                break;
            case 'double':
                $response = (double)$response;
                break;
        }

        return $response;
    }
public function get ( string $ configKey , string $ configFile = 'default' , ? string $ parseType = null ) { $ this -> load ( $ configFile ) ; // check if configs for this file is loaded if ( ! isset ( $ this -> data [ $ configFile ] ) ) { return false ; } // check if config key is exist if ( ! isset ( $ this -> data [ $ configFile ] [ $ configKey ] ) ) { return false ; } $ response = $ this -> data [ $ configFile ] [ $ configKey ] ; // try to convert config value by defined parse type $ parseType = Str :: lowerCase ( $ parseType ) ; switch ( $ parseType ) { case 'int' : case 'integer' : $ response = ( int ) $ response ; break ; case 'bool' : case 'boolean' : $ response = ( bool ) $ response ; break ; case 'float' : $ response = ( float ) $ response ; break ; case 'double' : $ response = ( double ) $ response ; break ; } return $ response ; }
Get config value by config key from configuration file
@param string $configKey
@param string $configFile
@param string|null $parseType
@return mixed
Get config value by config key from configuration file