PHP Classes

File: vendor/league/flysystem/src/Config.php

Recommend this page to a friend!
  Classes of Renato De Oliveira Lucena   PHP Pokemon Script   vendor/league/flysystem/src/Config.php   Download  
File: vendor/league/flysystem/src/Config.php
Role: Class source
Content type: text/plain
Description: Class source
Class: PHP Pokemon Script
Provides an API to manage a database of Pokemons
Author: By
Last change:
Date: 6 years ago
Size: 1,980 bytes
 

Contents

Class file image Download
<?php

namespace League\Flysystem;

class
Config
{
   
/**
     * @var array
     */
   
protected $settings = [];

   
/**
     * @var Config
     */
   
protected $fallback;

   
/**
     * Constructor.
     *
     * @param array $settings
     */
   
public function __construct(array $settings = [])
    {
       
$this->settings = $settings;
    }

   
/**
     * Get a setting.
     *
     * @param string $key
     * @param mixed $default
     *
     * @return mixed config setting or default when not found
     */
   
public function get($key, $default = null)
    {
        if ( !
array_key_exists($key, $this->settings)) {
            return
$this->getDefault($key, $default);
        }

        return
$this->settings[$key];
    }

   
/**
     * Check if an item exists by key.
     *
     * @param string $key
     *
     * @return bool
     */
   
public function has($key)
    {
        if (
array_key_exists($key, $this->settings)) {
            return
true;
        }

        return
$this->fallback instanceof Config
           
? $this->fallback->has($key)
            :
false;
    }

   
/**
     * Try to retrieve a default setting from a config fallback.
     *
     * @param string $key
     * @param mixed $default
     *
     * @return mixed config setting or default when not found
     */
   
protected function getDefault($key, $default)
    {
        if ( !
$this->fallback) {
            return
$default;
        }

        return
$this->fallback->get($key, $default);
    }

   
/**
     * Set a setting.
     *
     * @param string $key
     * @param mixed $value
     *
     * @return $this
     */
   
public function set($key, $value)
    {
       
$this->settings[$key] = $value;

        return
$this;
    }

   
/**
     * Set the fallback.
     *
     * @param Config $fallback
     *
     * @return $this
     */
   
public function setFallback(Config $fallback)
    {
       
$this->fallback = $fallback;

        return
$this;
    }
}