Pop\Project\Project::loadConfig PHP Method

loadConfig() public method

Load a project config
public loadConfig ( mixed $config ) : Project
$config mixed
return Project
    public function loadConfig($config)
    {
        // Test to see if the config is already set and changes are allowed.
        if (null !== $this->config && !$this->config->changesAllowed()) {
            throw new Exception('Real-time configuration changes are not allowed.');
        }
        // Else, set the new config
        if (is_array($config)) {
            $this->config = new Config($config);
        } else {
            if ($config instanceof Config) {
                $this->config = $config;
            } else {
                throw new Exception('The project config must be either an array or an instance of Pop\\Config.');
            }
        }
        return $this;
    }

Usage Example

Example #1
0
 public function testLoadConfigTypeExecption()
 {
     $this->setExpectedException('Pop\\Project\\Exception');
     $p = new Project();
     $p->loadConfig('bad config');
 }