Source of file Session.php

Size: 0,909 Bytes - Last Modified: 2015-12-22T09:12:14-05:00

../src/Traits/Session.php

12345678910111213141516171819202122232425262728293031323334353637383940
Covered by 1 test(s):
  • MvcLite\SessionTraitsTest::testGetSession
41
Covered by 1 test(s):
  • MvcLite\SessionTraitsTest::testGetSession
42
Covered by 1 test(s):
  • MvcLite\SessionTraitsTest::testGetSession
43
Covered by 1 test(s):
  • MvcLite\SessionTraitsTest::testGetSession
444546
<?php
/**
 * Session Trait
 *
 * @category   PHP
 * @package    MvcLite
 * @subpackage Traits
 * @since      File available since release 3.0.x
 * @author     Cory Collier <corycollier@corycollier.com>
 */

namespace MvcLite\Traits;

/**
 * Request Trait.
 *
 * Allows a getter for the requests instance.
 *
 * @category   PHP
 * @package    MvcLite
 * @subpackage Traits
 * @since      File available since release 3.0.x
 * @author     Cory Collier <corycollier@corycollier.com>
 */
trait Session
{
    /**
     * Session instance variable.
     * @var MvcLite\Session
     */
    protected $session;

    /**
     * Getter for the session instance variable.
     *
     * @return MvcLite\Session The session instance.
     */
    public function getSession()
    {
        if (!$this->session) {
            $this->session = \MvcLite\Session::getInstance();
        }
        return $this->session;
    }
}