Skip to content

Instantly share code, notes, and snippets.

View sankety's full-sized avatar
🎯
Focusing

Sanket sankety

🎯
Focusing
View GitHub Profile
@sankety
sankety / factoryDesignPatternDemo.php
Last active January 12, 2020 11:27
Demo for Factory Design Pattern in PHP
<?php
class FactoryMain
{
private $type;
function __construct($type)
{
$this->type = $type;
@sankety
sankety / singletonDesignPatternDemo.php
Last active January 6, 2020 11:27
Demo for Singleton design pattern in PHP
<?php
final class ASingleTon{
private static $counter = 0;
private static $instance = null;
public static function getInstance(){
if(!empty(ASingleTon::$instance)){
return ASingleTon::$instance;
}
ASingleTon::$instance = new ASingleTon();
return ASingleTon::$instance;