PHP Classes

File: src/loader/JsonLoader.php

Recommend this page to a friend!
  Classes of Vitaly   Queasy PHP Config   src/loader/JsonLoader.php   Download  
File: src/loader/JsonLoader.php
Role: Class source
Content type: text/plain
Description: Class source
Class: Queasy PHP Config
Read a configuration from files in several formats
Author: By
Last change:
Date: 3 years ago
Size: 807 bytes
 

Contents

Class file image Download
<?php

/*
 * Queasy PHP Framework - Configuration
 *
 * (c) Vitaly Demyanenko <vitaly_demyanenko@yahoo.com>
 *
 * For the full copyright and license information, please view the LICENSE file that was distributed with this source code.
 */

namespace queasy\config\loader;

/**
 * JSON configuration loader class
 */
class JsonLoader extends FileSystemLoader
{
   
/**
     * Load and return an array containing configuration.
     *
     * @return array Loaded configuration
     *
     * @throws ConfigLoaderException When file is corrupted
     */
   
public function load()
    {
       
$path = $this->path();

       
$data = json_decode(file_get_contents($path), true);
        if (!
is_array($data)) {
            throw new
CorruptedException($this->path());
        }

        return
$data;
    }
}