Skip to content

Commit

Permalink
change structure
Browse files Browse the repository at this point in the history
  • Loading branch information
Steeven Andrian committed Apr 29, 2019
1 parent e4173a4 commit 96bf277
Show file tree
Hide file tree
Showing 17 changed files with 1,197 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/Containers/SplClosureContainer.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

// ------------------------------------------------------------------------

use O2System\Psr\Container\ContainerInterface;
use Psr\Container\ContainerInterface;

/**
* Class SplClosureContainer
Expand Down
2 changes: 1 addition & 1 deletion src/Containers/SplServiceContainer.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

// ------------------------------------------------------------------------

use O2System\Psr\Container\ContainerInterface;
use Psr\Container\ContainerInterface;
use O2System\Spl\Containers\DataStructures\SplServiceRegistry;

/**
Expand Down
23 changes: 23 additions & 0 deletions src/Patterns/Creational/Factory/AbstractFactory.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php
/**
* This file is part of the O2System Framework package.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @author Steeve Andrian Salim
* @copyright Copyright (c) Steeve Andrian Salim
*/

// ------------------------------------------------------------------------

namespace O2System\Spl\Patterns\Creational\Factory;

/**
* Class AbstractFactory
* @package O2System\Spl\Patterns\Factory
*/
abstract class AbstractFactory implements PrototypeInterface
{

}
30 changes: 30 additions & 0 deletions src/Patterns/Creational/Factory/PrototypeInterface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php
/**
* This file is part of the O2System Framework package.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @author Steeve Andrian Salim
* @copyright Copyright (c) Steeve Andrian Salim
*/

// ------------------------------------------------------------------------

namespace O2System\Spl\Patterns\Creational\Factory;

/**
* Interface PrototypeInterface
* @package O2System\Spl\Patterns\Creational\Factory
*/
interface PrototypeInterface
{
/**
* PrototypeInterface::create
*
* @param array $config
*
* @return mixed
*/
public function create(array $config = []);
}
95 changes: 95 additions & 0 deletions src/Patterns/Creational/Singleton/AbstractSingleton.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
<?php
/**
* This file is part of the O2System Framework package.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @author Steeve Andrian Salim
* @copyright Copyright (c) Steeve Andrian Salim
*/

// ------------------------------------------------------------------------

namespace O2System\Spl\Patterns\Creational\Singleton;

/**
* Class AbstractSingleton
* @package O2System\Spl\Patterns\Creational\Singleton
*/
class AbstractSingleton implements InstanceInterface
{
/**
* AbstractSingleton::$instance
*
* Singleton Instance
*
* @var static
*/
protected static $instance;

// ------------------------------------------------------------------------

/**
* AbstractSingleton::__construct
*
* Protected constructor to prevent creating a new instance of the
* *Singleton* via the `new` operator from outside of this class.
*/
protected function __construct()
{
static::$instance =& $this;
}

// ------------------------------------------------------------------------

/**
* AbstractSingleton::getInstance
*
* Returns the *Singleton* instance of this class.
*
* @return static Returns the instance class
*/
public static function getInstance()
{
if (empty(static::$instance)) {
$className = get_called_class();

static::$instance = new $className();

if (method_exists(static::$instance, '__reconstruct')) {
call_user_func_array([&static::$instance, '__reconstruct'], func_get_args());
}
}

return static::$instance;
}

// ------------------------------------------------------------------------

/**
* AbstractSingleton::__clone
*
* Application of __clone magic method with private visibility to prevent cloning of
* the *Singleton* instance.
*
* @return void
*/
protected function __clone()
{
}

// ------------------------------------------------------------------------

/**
* AbstractSingleton::__wakeup
*
* Application of __wakeup magic method with private visibiliry to prevent unserializing of
* the *Singleton* instance.
*
* @return void
*/
protected function __wakeup()
{
}
}
28 changes: 28 additions & 0 deletions src/Patterns/Creational/Singleton/InstanceInterface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php
/**
* This file is part of the O2System Framework package.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @author Steeve Andrian Salim
* @copyright Copyright (c) Steeve Andrian Salim
*/

// ------------------------------------------------------------------------

namespace O2System\Spl\Patterns\Creational\Singleton;

/**
* Interface InstanceInterface
* @package O2System\Spl\Patterns\Creational\Singleton
*/
interface InstanceInterface
{
/**
* InstanceInterface::getInstance
*
* @return object
*/
public static function getInstance();
}
33 changes: 33 additions & 0 deletions src/Patterns/Structural/Assemble/AbstractAssemble.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?php
/**
* This file is part of the O2System Framework package.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @author Steeve Andrian Salim
* @copyright Copyright (c) Steeve Andrian Salim
*/

// ------------------------------------------------------------------------

namespace O2System\Spl\Patterns\Structural\Assemble;

/**
* Class AbstractAssemble
* @package O2System\Spl\Patterns\Assemble
*/
abstract class AbstractAssemble implements CollectorInterface
{
protected $collection = [];

public function collect()
{

}

public function &getCollection($offset)
{

}
}
30 changes: 30 additions & 0 deletions src/Patterns/Structural/Assemble/CollectorInterface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php
/**
* This file is part of the O2System Framework package.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @author Steeve Andrian Salim
* @copyright Copyright (c) Steeve Andrian Salim
*/

// ------------------------------------------------------------------------

namespace O2System\Spl\Patterns\Structural\Assemble;

/**
* Interface CollectorInterface
* @package O2System\Spl\Patterns\Assemble
*/
interface CollectorInterface
{
/**
* CollectorInterface::collect
*
* Collection process.
*
* @return void
*/
public function collect();
}
23 changes: 23 additions & 0 deletions src/Patterns/Structural/Composite/AbstractComposite.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php
/**
* This file is part of the O2System Framework package.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @author Steeve Andrian Salim
* @copyright Copyright (c) Steeve Andrian Salim
*/

// ------------------------------------------------------------------------

namespace O2System\Spl\Patterns\Structural\Composite;

/**
* Class AbstractBuilder
* @package O2System\Spl\Patterns\Builder
*/
abstract class AbstractComposite implements RenderableInterface
{

}
30 changes: 30 additions & 0 deletions src/Patterns/Structural/Composite/RenderableInterface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php
/**
* This file is part of the O2System Framework package.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @author Steeve Andrian Salim
* @copyright Copyright (c) Steeve Andrian Salim
*/

// ------------------------------------------------------------------------

namespace O2System\Spl\Patterns\Structural\Composite;

/**
* Interface RenderableInterface
* @package O2System\Spl\Patterns\Structural\Composite
*/
interface RenderableInterface
{
/**
* RenderableInterface::render
*
* @param array $options
*
* @return mixed
*/
public function render(array $options = []);
}
25 changes: 25 additions & 0 deletions src/Patterns/Structural/Facade/AbstractFacade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php
/**
* This file is part of the O2System Framework package.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @author Steeve Andrian Salim
* @copyright Copyright (c) Steeve Andrian Salim
*/

// ------------------------------------------------------------------------

namespace O2System\Spl\Patterns\Structural\Facade;

// ------------------------------------------------------------------------

/**
* Class AbstractFacade
* @package O2System\Spl\Patterns\Structural\Facade
*/
abstract class AbstractFacade implements ProcessorInterface
{

}
32 changes: 32 additions & 0 deletions src/Patterns/Structural/Facade/ProcessorInterface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php
/**
* This file is part of the O2System Framework package.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @author Steeve Andrian Salim
* @copyright Copyright (c) Steeve Andrian Salim
*/

// ------------------------------------------------------------------------

namespace O2System\Spl\Patterns\Structural\Facade;

// ------------------------------------------------------------------------

/**
* Interface ProcessorInterface
* @package O2System\Spl\Patterns\Structural\Facade
*/
interface ProcessorInterface
{
/**
* ProcessorInterface::process
*
* Processor process.
*
* @return void
*/
public function process();
}
Loading

0 comments on commit 96bf277

Please sign in to comment.