Skip to content
This repository has been archived by the owner on Jul 30, 2020. It is now read-only.

Commit

Permalink
add shared instance
Browse files Browse the repository at this point in the history
  • Loading branch information
rez1dent3 committed May 2, 2017
1 parent def0d0f commit 34151e1
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 4 deletions.
6 changes: 2 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
composer.phar
/vendor/

# Commit your application's lock file http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file
# You may choose to ignore a library lock file http://getcomposer.org/doc/02-libraries.md#lock-file
# composer.lock
composer.lock
.idea
16 changes: 16 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"name": "bavix/foundation",
"description": "foundation",
"license": "MIT",
"authors": [
{
"name": "REZ1DENT3",
"email": "info@babichev.net"
}
],
"autoload": {
"psr-4": {
"Bavix\\": "src/"
}
}
}
23 changes: 23 additions & 0 deletions src/Foundation/SharedInstance.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php

namespace Bavix\Foundation;

trait SharedInstance
{

/**
* @return static
*/
public static function sharedInstance()
{
static $sharedInstance;

if (!$sharedInstance)
{
$sharedInstance = new static();
}

return $sharedInstance;
}

}

0 comments on commit 34151e1

Please sign in to comment.