Source of file Singleton.php

Size: 1,041 Bytes - Last Modified: 2015-12-22T09:12:14-05:00

../src/Traits/Singleton.php

12345678910111213141516171819202122232425262728293031323334353637383940
Covered by 22 test(s):
  • MvcLite\CacheTest::testInit with data set "with prefix"
  • MvcLite\ConfigTest::testSet with data set #0
  • MvcLite\DispatcherTest::testDispatch with data set "good controller request"
  • MvcLite\DispatcherTest::testDispatch with data set "bad controller request"
  • MvcLite\ErrorTest::testHandle with data set #0
  • MvcLite\RequestTest::testBuildFromString with data set "simple test"
  • MvcLite\ResponseTest::testSetBody
  • MvcLite\ResponseTest::testSendHeaders with data set "simple test"
  • MvcLite\SessionTest::testInit with data set "simple test"
  • MvcLite\SessionTest::testSetParams with data set "simple test"
  • MvcLite\SessionTest::testDestroy with data set "simple test"
  • MvcLite\ViewTest::testInit
  • MvcLite\ViewTest::testGetHelper with data set "Csv helper"
  • MvcLite\ViewTest::testGetHelper with data set "Exception helper"
  • MvcLite\ViewTest::testGetHelper with data set "InputCheckbox helper"
  • MvcLite\ViewTest::testGetHelper with data set "InputPassword helper"
  • MvcLite\ViewTest::testGetHelper with data set "InputSelect helper"
  • MvcLite\ViewTest::testGetHelper with data set "InputSubmit helper"
  • MvcLite\ViewTest::testGetHelper with data set "InputTextarea helper"
  • MvcLite\ViewTest::testGetHelper with data set "InputText helper"
  • MvcLite\ViewTest::testGetHelper with data set "InputText helper, but already has it"
  • MvcLite\ViewTest::testGetHelper with data set "Bad Helper, expect exception"
414243444546474849
Covered by 91 test(s):
  • MvcLite\CacheTest::testInit with data set "with prefix"
  • MvcLite\CacheTest::testInit with data set "without prefix"
  • MvcLite\CacheTest::testSet with data set #0
  • MvcLite\CacheTest::testSet with data set #1
  • MvcLite\CacheTest::testSet with data set #2
  • MvcLite\CacheTest::testGetCacheKey with data set "simple testing"
  • MvcLite\ConfigTest::testSet with data set #0
  • MvcLite\ConfigTest::testSet with data set #1
  • MvcLite\ConfigTest::testSet with data set #2
  • MvcLite\ConfigTest::testSet with data set #3
  • MvcLite\ConfigTest::testSet with data set #4
  • MvcLite\ConfigTest::testGet with data set "key exists, expect value"
  • MvcLite\ConfigTest::testGet with data set "key does not exist, do notexpect value"
  • MvcLite\ConfigTest::testGetSection with data set "empty everything"
  • MvcLite\ConfigTest::testGetSection with data set "empty data"
  • MvcLite\ConfigTest::testGetSection with data set "empty expected"
  • MvcLite\ConfigTest::testGetSection with data set "expectations"
  • MvcLite\DispatcherTest::testDispatch with data set "good controller request"
  • MvcLite\DispatcherTest::testDispatch with data set "bad controller request"
  • MvcLite\ErrorTest::testHandle with data set #0
  • MvcLite\ErrorTest::testHandle with data set #1
  • MvcLite\ErrorTest::testHandle with data set #2
  • MvcLite\ErrorTest::testHandle with data set #3
  • MvcLite\ErrorTest::testGetErrors with data set #0
  • MvcLite\RequestTest::testBuildFromString with data set "simple test"
  • MvcLite\RequestTest::testBuildFromString with data set "tricky test"
  • MvcLite\RequestTest::testGetParams
  • MvcLite\RequestTest::testGetParam
  • MvcLite\RequestTest::testIsPost
  • MvcLite\RequestTest::testGetHeaders with data set "simple test"
  • MvcLite\RequestTest::testSetHeaders with data set "no http headers"
  • MvcLite\RequestTest::testSetHeaders with data set "one http headers"
  • MvcLite\RequestTest::testSetHeaders with data set "with content type"
  • MvcLite\RequestTest::testSetHeader
  • MvcLite\RequestTest::testIsAjax
  • MvcLite\RequestTest::testGetUri
  • MvcLite\RequestTest::testGetFormat with data set "application/json"
  • MvcLite\RequestTest::testGetFormat with data set "application/javascript"
  • MvcLite\RequestTest::testGetFormat with data set "text/html"
  • MvcLite\RequestTest::testGetFormat with data set "text/plain"
  • MvcLite\RequestTest::testGetFormat with data set "text/csv"
  • MvcLite\RequestTest::testGetFormat with data set "bad content type, expect exception"
  • MvcLite\RequestTest::testGetContentType with data set "has content type text/plain"
  • MvcLite\RequestTest::testGetContentType with data set "has no content type, but has accept headers"
  • MvcLite\RequestTest::testGetContentType with data set "has nothing"
  • MvcLite\ResponseTest::testSetBody
  • MvcLite\ResponseTest::testGetBody
  • MvcLite\ResponseTest::testSetHeader with data set "plain content headers"
  • MvcLite\ResponseTest::testSetHeader with data set "csv content headers"
  • MvcLite\ResponseTest::testSetHeader with data set "testing headers"
  • MvcLite\ResponseTest::testGetHeaders
  • MvcLite\ResponseTest::testGetHeader
  • MvcLite\ResponseTest::testSendHeaders with data set "simple test"
  • MvcLite\ResponseTest::testSetContentType with data set "No content type"
  • MvcLite\ResponseTest::testSetContentType with data set "Good content type (application/json)"
  • MvcLite\ResponseTest::testSetContentType with data set "Good content type (application/javascript)"
  • MvcLite\ResponseTest::testSetContentType with data set "Good content type (text/html)"
  • MvcLite\ResponseTest::testSetContentType with data set "Good content type (text/plain)"
  • MvcLite\ResponseTest::testSetContentType with data set "Good content type (text/csv)"
  • MvcLite\ResponseTest::testSetContentType with data set "Bad content type, expect exception"
  • MvcLite\ResponseTest::testGetContentType with data set "has header, expect it"
  • MvcLite\ResponseTest::testGetContentType with data set "does not have header, expect default"
  • MvcLite\SessionTest::testInit with data set "simple test"
  • MvcLite\SessionTest::testSetParams with data set "simple test"
  • MvcLite\SessionTest::testGetParams with data set "simple test"
  • MvcLite\SessionTest::testSetParam with data set "simple test"
  • MvcLite\SessionTest::testDestroy with data set "simple test"
  • MvcLite\ConfigTraitsTest::testGetConfig
  • MvcLite\SessionTraitsTest::testGetSession
  • MvcLite\ViewTest::testInit
  • MvcLite\ViewTest::testFilter
  • MvcLite\ViewTest::testSetAndGet with data set "first test"
  • MvcLite\ViewTest::testGetViewScript with data set "file does not exist"
  • MvcLite\ViewTest::testGetViewScript with data set "file does exist"
  • MvcLite\ViewTest::testAddViewScriptPath with data set "path not in APP_PATH"
  • MvcLite\ViewTest::testAddViewScriptPath with data set "path in APP_PATH"
  • MvcLite\ViewTest::testGetFormat
  • MvcLite\ViewTest::testSetFormat with data set "json"
  • MvcLite\ViewTest::testSetFormat with data set "html"
  • MvcLite\ViewTest::testSetFormat with data set "plain"
  • MvcLite\ViewTest::testSetFormat with data set "xml"
  • MvcLite\ViewTest::testGetHelper with data set "Csv helper"
  • MvcLite\ViewTest::testGetHelper with data set "Exception helper"
  • MvcLite\ViewTest::testGetHelper with data set "InputCheckbox helper"
  • MvcLite\ViewTest::testGetHelper with data set "InputPassword helper"
  • MvcLite\ViewTest::testGetHelper with data set "InputSelect helper"
  • MvcLite\ViewTest::testGetHelper with data set "InputSubmit helper"
  • MvcLite\ViewTest::testGetHelper with data set "InputTextarea helper"
  • MvcLite\ViewTest::testGetHelper with data set "InputText helper"
  • MvcLite\ViewTest::testGetHelper with data set "InputText helper, but already has it"
  • MvcLite\ViewTest::testGetHelper with data set "Bad Helper, expect exception"
50
Covered by 91 test(s):
  • MvcLite\CacheTest::testInit with data set "with prefix"
  • MvcLite\CacheTest::testInit with data set "without prefix"
  • MvcLite\CacheTest::testSet with data set #0
  • MvcLite\CacheTest::testSet with data set #1
  • MvcLite\CacheTest::testSet with data set #2
  • MvcLite\CacheTest::testGetCacheKey with data set "simple testing"
  • MvcLite\ConfigTest::testSet with data set #0
  • MvcLite\ConfigTest::testSet with data set #1
  • MvcLite\ConfigTest::testSet with data set #2
  • MvcLite\ConfigTest::testSet with data set #3
  • MvcLite\ConfigTest::testSet with data set #4
  • MvcLite\ConfigTest::testGet with data set "key exists, expect value"
  • MvcLite\ConfigTest::testGet with data set "key does not exist, do notexpect value"
  • MvcLite\ConfigTest::testGetSection with data set "empty everything"
  • MvcLite\ConfigTest::testGetSection with data set "empty data"
  • MvcLite\ConfigTest::testGetSection with data set "empty expected"
  • MvcLite\ConfigTest::testGetSection with data set "expectations"
  • MvcLite\DispatcherTest::testDispatch with data set "good controller request"
  • MvcLite\DispatcherTest::testDispatch with data set "bad controller request"
  • MvcLite\ErrorTest::testHandle with data set #0
  • MvcLite\ErrorTest::testHandle with data set #1
  • MvcLite\ErrorTest::testHandle with data set #2
  • MvcLite\ErrorTest::testHandle with data set #3
  • MvcLite\ErrorTest::testGetErrors with data set #0
  • MvcLite\RequestTest::testBuildFromString with data set "simple test"
  • MvcLite\RequestTest::testBuildFromString with data set "tricky test"
  • MvcLite\RequestTest::testGetParams
  • MvcLite\RequestTest::testGetParam
  • MvcLite\RequestTest::testIsPost
  • MvcLite\RequestTest::testGetHeaders with data set "simple test"
  • MvcLite\RequestTest::testSetHeaders with data set "no http headers"
  • MvcLite\RequestTest::testSetHeaders with data set "one http headers"
  • MvcLite\RequestTest::testSetHeaders with data set "with content type"
  • MvcLite\RequestTest::testSetHeader
  • MvcLite\RequestTest::testIsAjax
  • MvcLite\RequestTest::testGetUri
  • MvcLite\RequestTest::testGetFormat with data set "application/json"
  • MvcLite\RequestTest::testGetFormat with data set "application/javascript"
  • MvcLite\RequestTest::testGetFormat with data set "text/html"
  • MvcLite\RequestTest::testGetFormat with data set "text/plain"
  • MvcLite\RequestTest::testGetFormat with data set "text/csv"
  • MvcLite\RequestTest::testGetFormat with data set "bad content type, expect exception"
  • MvcLite\RequestTest::testGetContentType with data set "has content type text/plain"
  • MvcLite\RequestTest::testGetContentType with data set "has no content type, but has accept headers"
  • MvcLite\RequestTest::testGetContentType with data set "has nothing"
  • MvcLite\ResponseTest::testSetBody
  • MvcLite\ResponseTest::testGetBody
  • MvcLite\ResponseTest::testSetHeader with data set "plain content headers"
  • MvcLite\ResponseTest::testSetHeader with data set "csv content headers"
  • MvcLite\ResponseTest::testSetHeader with data set "testing headers"
  • MvcLite\ResponseTest::testGetHeaders
  • MvcLite\ResponseTest::testGetHeader
  • MvcLite\ResponseTest::testSendHeaders with data set "simple test"
  • MvcLite\ResponseTest::testSetContentType with data set "No content type"
  • MvcLite\ResponseTest::testSetContentType with data set "Good content type (application/json)"
  • MvcLite\ResponseTest::testSetContentType with data set "Good content type (application/javascript)"
  • MvcLite\ResponseTest::testSetContentType with data set "Good content type (text/html)"
  • MvcLite\ResponseTest::testSetContentType with data set "Good content type (text/plain)"
  • MvcLite\ResponseTest::testSetContentType with data set "Good content type (text/csv)"
  • MvcLite\ResponseTest::testSetContentType with data set "Bad content type, expect exception"
  • MvcLite\ResponseTest::testGetContentType with data set "has header, expect it"
  • MvcLite\ResponseTest::testGetContentType with data set "does not have header, expect default"
  • MvcLite\SessionTest::testInit with data set "simple test"
  • MvcLite\SessionTest::testSetParams with data set "simple test"
  • MvcLite\SessionTest::testGetParams with data set "simple test"
  • MvcLite\SessionTest::testSetParam with data set "simple test"
  • MvcLite\SessionTest::testDestroy with data set "simple test"
  • MvcLite\ConfigTraitsTest::testGetConfig
  • MvcLite\SessionTraitsTest::testGetSession
  • MvcLite\ViewTest::testInit
  • MvcLite\ViewTest::testFilter
  • MvcLite\ViewTest::testSetAndGet with data set "first test"
  • MvcLite\ViewTest::testGetViewScript with data set "file does not exist"
  • MvcLite\ViewTest::testGetViewScript with data set "file does exist"
  • MvcLite\ViewTest::testAddViewScriptPath with data set "path not in APP_PATH"
  • MvcLite\ViewTest::testAddViewScriptPath with data set "path in APP_PATH"
  • MvcLite\ViewTest::testGetFormat
  • MvcLite\ViewTest::testSetFormat with data set "json"
  • MvcLite\ViewTest::testSetFormat with data set "html"
  • MvcLite\ViewTest::testSetFormat with data set "plain"
  • MvcLite\ViewTest::testSetFormat with data set "xml"
  • MvcLite\ViewTest::testGetHelper with data set "Csv helper"
  • MvcLite\ViewTest::testGetHelper with data set "Exception helper"
  • MvcLite\ViewTest::testGetHelper with data set "InputCheckbox helper"
  • MvcLite\ViewTest::testGetHelper with data set "InputPassword helper"
  • MvcLite\ViewTest::testGetHelper with data set "InputSelect helper"
  • MvcLite\ViewTest::testGetHelper with data set "InputSubmit helper"
  • MvcLite\ViewTest::testGetHelper with data set "InputTextarea helper"
  • MvcLite\ViewTest::testGetHelper with data set "InputText helper"
  • MvcLite\ViewTest::testGetHelper with data set "InputText helper, but already has it"
  • MvcLite\ViewTest::testGetHelper with data set "Bad Helper, expect exception"
51
Covered by 22 test(s):
  • MvcLite\CacheTest::testInit with data set "with prefix"
  • MvcLite\ConfigTest::testSet with data set #0
  • MvcLite\DispatcherTest::testDispatch with data set "good controller request"
  • MvcLite\DispatcherTest::testDispatch with data set "bad controller request"
  • MvcLite\ErrorTest::testHandle with data set #0
  • MvcLite\RequestTest::testBuildFromString with data set "simple test"
  • MvcLite\ResponseTest::testSetBody
  • MvcLite\ResponseTest::testSendHeaders with data set "simple test"
  • MvcLite\SessionTest::testInit with data set "simple test"
  • MvcLite\SessionTest::testSetParams with data set "simple test"
  • MvcLite\SessionTest::testDestroy with data set "simple test"
  • MvcLite\ViewTest::testInit
  • MvcLite\ViewTest::testGetHelper with data set "Csv helper"
  • MvcLite\ViewTest::testGetHelper with data set "Exception helper"
  • MvcLite\ViewTest::testGetHelper with data set "InputCheckbox helper"
  • MvcLite\ViewTest::testGetHelper with data set "InputPassword helper"
  • MvcLite\ViewTest::testGetHelper with data set "InputSelect helper"
  • MvcLite\ViewTest::testGetHelper with data set "InputSubmit helper"
  • MvcLite\ViewTest::testGetHelper with data set "InputTextarea helper"
  • MvcLite\ViewTest::testGetHelper with data set "InputText helper"
  • MvcLite\ViewTest::testGetHelper with data set "InputText helper, but already has it"
  • MvcLite\ViewTest::testGetHelper with data set "Bad Helper, expect exception"
52
Covered by 22 test(s):
  • MvcLite\CacheTest::testInit with data set "with prefix"
  • MvcLite\ConfigTest::testSet with data set #0
  • MvcLite\DispatcherTest::testDispatch with data set "good controller request"
  • MvcLite\DispatcherTest::testDispatch with data set "bad controller request"
  • MvcLite\ErrorTest::testHandle with data set #0
  • MvcLite\RequestTest::testBuildFromString with data set "simple test"
  • MvcLite\ResponseTest::testSetBody
  • MvcLite\ResponseTest::testSendHeaders with data set "simple test"
  • MvcLite\SessionTest::testInit with data set "simple test"
  • MvcLite\SessionTest::testSetParams with data set "simple test"
  • MvcLite\SessionTest::testDestroy with data set "simple test"
  • MvcLite\ViewTest::testInit
  • MvcLite\ViewTest::testGetHelper with data set "Csv helper"
  • MvcLite\ViewTest::testGetHelper with data set "Exception helper"
  • MvcLite\ViewTest::testGetHelper with data set "InputCheckbox helper"
  • MvcLite\ViewTest::testGetHelper with data set "InputPassword helper"
  • MvcLite\ViewTest::testGetHelper with data set "InputSelect helper"
  • MvcLite\ViewTest::testGetHelper with data set "InputSubmit helper"
  • MvcLite\ViewTest::testGetHelper with data set "InputTextarea helper"
  • MvcLite\ViewTest::testGetHelper with data set "InputText helper"
  • MvcLite\ViewTest::testGetHelper with data set "InputText helper, but already has it"
  • MvcLite\ViewTest::testGetHelper with data set "Bad Helper, expect exception"
53
Covered by 91 test(s):
  • MvcLite\CacheTest::testInit with data set "with prefix"
  • MvcLite\CacheTest::testInit with data set "without prefix"
  • MvcLite\CacheTest::testSet with data set #0
  • MvcLite\CacheTest::testSet with data set #1
  • MvcLite\CacheTest::testSet with data set #2
  • MvcLite\CacheTest::testGetCacheKey with data set "simple testing"
  • MvcLite\ConfigTest::testSet with data set #0
  • MvcLite\ConfigTest::testSet with data set #1
  • MvcLite\ConfigTest::testSet with data set #2
  • MvcLite\ConfigTest::testSet with data set #3
  • MvcLite\ConfigTest::testSet with data set #4
  • MvcLite\ConfigTest::testGet with data set "key exists, expect value"
  • MvcLite\ConfigTest::testGet with data set "key does not exist, do notexpect value"
  • MvcLite\ConfigTest::testGetSection with data set "empty everything"
  • MvcLite\ConfigTest::testGetSection with data set "empty data"
  • MvcLite\ConfigTest::testGetSection with data set "empty expected"
  • MvcLite\ConfigTest::testGetSection with data set "expectations"
  • MvcLite\DispatcherTest::testDispatch with data set "good controller request"
  • MvcLite\DispatcherTest::testDispatch with data set "bad controller request"
  • MvcLite\ErrorTest::testHandle with data set #0
  • MvcLite\ErrorTest::testHandle with data set #1
  • MvcLite\ErrorTest::testHandle with data set #2
  • MvcLite\ErrorTest::testHandle with data set #3
  • MvcLite\ErrorTest::testGetErrors with data set #0
  • MvcLite\RequestTest::testBuildFromString with data set "simple test"
  • MvcLite\RequestTest::testBuildFromString with data set "tricky test"
  • MvcLite\RequestTest::testGetParams
  • MvcLite\RequestTest::testGetParam
  • MvcLite\RequestTest::testIsPost
  • MvcLite\RequestTest::testGetHeaders with data set "simple test"
  • MvcLite\RequestTest::testSetHeaders with data set "no http headers"
  • MvcLite\RequestTest::testSetHeaders with data set "one http headers"
  • MvcLite\RequestTest::testSetHeaders with data set "with content type"
  • MvcLite\RequestTest::testSetHeader
  • MvcLite\RequestTest::testIsAjax
  • MvcLite\RequestTest::testGetUri
  • MvcLite\RequestTest::testGetFormat with data set "application/json"
  • MvcLite\RequestTest::testGetFormat with data set "application/javascript"
  • MvcLite\RequestTest::testGetFormat with data set "text/html"
  • MvcLite\RequestTest::testGetFormat with data set "text/plain"
  • MvcLite\RequestTest::testGetFormat with data set "text/csv"
  • MvcLite\RequestTest::testGetFormat with data set "bad content type, expect exception"
  • MvcLite\RequestTest::testGetContentType with data set "has content type text/plain"
  • MvcLite\RequestTest::testGetContentType with data set "has no content type, but has accept headers"
  • MvcLite\RequestTest::testGetContentType with data set "has nothing"
  • MvcLite\ResponseTest::testSetBody
  • MvcLite\ResponseTest::testGetBody
  • MvcLite\ResponseTest::testSetHeader with data set "plain content headers"
  • MvcLite\ResponseTest::testSetHeader with data set "csv content headers"
  • MvcLite\ResponseTest::testSetHeader with data set "testing headers"
  • MvcLite\ResponseTest::testGetHeaders
  • MvcLite\ResponseTest::testGetHeader
  • MvcLite\ResponseTest::testSendHeaders with data set "simple test"
  • MvcLite\ResponseTest::testSetContentType with data set "No content type"
  • MvcLite\ResponseTest::testSetContentType with data set "Good content type (application/json)"
  • MvcLite\ResponseTest::testSetContentType with data set "Good content type (application/javascript)"
  • MvcLite\ResponseTest::testSetContentType with data set "Good content type (text/html)"
  • MvcLite\ResponseTest::testSetContentType with data set "Good content type (text/plain)"
  • MvcLite\ResponseTest::testSetContentType with data set "Good content type (text/csv)"
  • MvcLite\ResponseTest::testSetContentType with data set "Bad content type, expect exception"
  • MvcLite\ResponseTest::testGetContentType with data set "has header, expect it"
  • MvcLite\ResponseTest::testGetContentType with data set "does not have header, expect default"
  • MvcLite\SessionTest::testInit with data set "simple test"
  • MvcLite\SessionTest::testSetParams with data set "simple test"
  • MvcLite\SessionTest::testGetParams with data set "simple test"
  • MvcLite\SessionTest::testSetParam with data set "simple test"
  • MvcLite\SessionTest::testDestroy with data set "simple test"
  • MvcLite\ConfigTraitsTest::testGetConfig
  • MvcLite\SessionTraitsTest::testGetSession
  • MvcLite\ViewTest::testInit
  • MvcLite\ViewTest::testFilter
  • MvcLite\ViewTest::testSetAndGet with data set "first test"
  • MvcLite\ViewTest::testGetViewScript with data set "file does not exist"
  • MvcLite\ViewTest::testGetViewScript with data set "file does exist"
  • MvcLite\ViewTest::testAddViewScriptPath with data set "path not in APP_PATH"
  • MvcLite\ViewTest::testAddViewScriptPath with data set "path in APP_PATH"
  • MvcLite\ViewTest::testGetFormat
  • MvcLite\ViewTest::testSetFormat with data set "json"
  • MvcLite\ViewTest::testSetFormat with data set "html"
  • MvcLite\ViewTest::testSetFormat with data set "plain"
  • MvcLite\ViewTest::testSetFormat with data set "xml"
  • MvcLite\ViewTest::testGetHelper with data set "Csv helper"
  • MvcLite\ViewTest::testGetHelper with data set "Exception helper"
  • MvcLite\ViewTest::testGetHelper with data set "InputCheckbox helper"
  • MvcLite\ViewTest::testGetHelper with data set "InputPassword helper"
  • MvcLite\ViewTest::testGetHelper with data set "InputSelect helper"
  • MvcLite\ViewTest::testGetHelper with data set "InputSubmit helper"
  • MvcLite\ViewTest::testGetHelper with data set "InputTextarea helper"
  • MvcLite\ViewTest::testGetHelper with data set "InputText helper"
  • MvcLite\ViewTest::testGetHelper with data set "InputText helper, but already has it"
  • MvcLite\ViewTest::testGetHelper with data set "Bad Helper, expect exception"
545556
<?php
/**
 * Singleton Trait
 *
 * @category   PHP
 * @package    MvcLite
 * @subpackage Traits
 * @since      File available since release 3.0.x
 * @author     Cory Collier <corycollier@corycollier.com>
 */


namespace MvcLite\Traits;

/**
 * Singleton Trait.
 *
 * Allows getting a single instance of self.
 *
 * @category   PHP
 * @package    MvcLite
 * @subpackage Traits
 * @since      File available since release 3.0.x
 * @author     Cory Collier <corycollier@corycollier.com>
 */
trait Singleton
{
    /**
     * Static instance variable
     * @var Singleton
     */
    protected static $instance;

    /**
     * Privatizing the constructor to protect the singleton pattern.
     */
    private function __construct()
    {

    }

    /**
     * Getter for the instance variable.
     *
     * @return Singleton
     */
    public static function getInstance()
    {
        $self = get_called_class();
        if (!$self::$instance) {
            $self::$instance = new $self;
        }
        return $self::$instance;
    }
}