pocketmine\utils\Config::load PHP Method

load() public method

public load ( $file, integer $type = Config::DETECT, array $default = [] ) : boolean
$file
$type integer
$default array
return boolean
    public function load($file, $type = Config::DETECT, $default = [])
    {
        $this->correct = true;
        $this->type = (int) $type;
        $this->file = $file;
        if (!is_array($default)) {
            $default = [];
        }
        if (!file_exists($file)) {
            $this->config = $default;
            $this->save();
        } else {
            if ($this->type === Config::DETECT) {
                $extension = explode(".", basename($this->file));
                $extension = strtolower(trim(array_pop($extension)));
                if (isset(Config::$formats[$extension])) {
                    $this->type = Config::$formats[$extension];
                } else {
                    $this->correct = false;
                }
            }
            if ($this->correct === true) {
                $content = file_get_contents($this->file);
                switch ($this->type) {
                    case Config::PROPERTIES:
                    case Config::CNF:
                        $this->parseProperties($content);
                        break;
                    case Config::JSON:
                        $this->config = json_decode($content, true);
                        break;
                    case Config::YAML:
                        $content = self::fixYAMLIndexes($content);
                        $this->config = yaml_parse($content);
                        break;
                    case Config::SERIALIZED:
                        $this->config = unserialize($content);
                        break;
                    case Config::ENUM:
                        $this->parseList($content);
                        break;
                    default:
                        $this->correct = false;
                        return false;
                }
                if (!is_array($this->config)) {
                    $this->config = $default;
                }
                if ($this->fillDefaults($default, $this->config) > 0) {
                    $this->save();
                }
            } else {
                return false;
            }
        }
        return true;
    }