Skip to content

Commit

Permalink
cleaned up the factory
Browse files Browse the repository at this point in the history
cleaned up the factory and converted the tests to use it
  • Loading branch information
excellentingenuity committed Oct 5, 2015
1 parent f83a875 commit 8b314b5
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 18 deletions.
4 changes: 2 additions & 2 deletions config/ImaginatorConfiguration.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
return [
'Record Persistance Provider' => 'ImaginatorFileRecordPersistance',
'File Persistance Provider' => '',
'Record Persistence Provider' => 'eig\Imaginator\Providers\ImaginatorFileRecordPersistence',
'File Persistence Provider' => '',
'Images Directory' => 'public/images',
'Directory Structure' => '',
'File Naming Convention' => '',
Expand Down
26 changes: 13 additions & 13 deletions src/Imaginator/Factory/ImaginatorFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

class ImaginatorFactory
{
protected $configFiles = [
protected static $configFiles = [
[
'source' => 'ImaginatorConfiguration.php',
'path' => 'config/',
Expand All @@ -19,22 +19,22 @@ class ImaginatorFactory
],
];

protected $packageConfig;
protected static $packageConfig;

protected $configOptions;
protected static $configOptions;

protected function loadConfiguration ()
protected static function loadConfiguration ()
{
// set the Configurator Options
// including the basePath for where the configuration file exists
$this->configOptions = new ConfigOptions();
$this->configOptions->basePath = realpath('config');
self::$configOptions = new ConfigOptions();
self::$configOptions->basePath = realpath('config');
try
{
// try to load and Configurator Configuration for Imaginator
$this->packageConfig = new Config(
$this->configFiles,
$this->configOptions
self::$packageConfig = new Config(
self::$configFiles,
self::$configOptions
);
} catch (\Exception $exception)
{
Expand All @@ -46,13 +46,13 @@ protected function loadConfiguration ()
}
}

protected function packageConfig()
protected static function packageConfig()
{
return $this->packageConfig;
return self::$packageConfig;
}

protected function getPersistenceProvider() {
return $this->packageConfig['Imaginator']['Record Persistance Provider'];
protected static function getPersistenceProvider() {
return new self::$packageConfig['Imaginator']['Record Persistence Provider']();
}

public static function make()
Expand Down
7 changes: 4 additions & 3 deletions tests/imaginatorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace eig\Imaginator\Tests;

use eig\Imaginator\Factory\ImaginatorFactory;
use eig\Imaginator\Imaginator;
use StevenWadeJr\Exposure\Factory;

Expand All @@ -19,7 +20,7 @@ class ImaginatorTest extends \PHPUnit_Framework_TestCase

public function setup ()
{
$this->imaginator = new Imaginator();
$this->imaginator = ImaginatorFactory::make();

}

Expand All @@ -32,7 +33,7 @@ public function testConstructor()
{
$this->assertInstanceOf(
'eig\Imaginator\Imaginator',
new Imaginator('example\imaginator.json')
ImaginatorFactory::make()
);
}

Expand All @@ -44,7 +45,7 @@ public function testConstructor()
*/
public function testConfigImagesDir()
{
$this->exposedImaginator = Factory::expose(new Imaginator);
$this->exposedImaginator = Factory::expose(ImaginatorFactory::make());
$this->assertEquals(
'public/images',
$this->exposedImaginator->config['Images Directory']
Expand Down

0 comments on commit 8b314b5

Please sign in to comment.