<?php
require_once 'UserStateInterface.php';
require_once 
'UnauthorizedState.php';

class 
AuthorizedState implements UserStateInterface
{
    private static 
$_singleton null;

    private function 
__construct()
    {
    }

    public static function 
getInstance()
    {
        if (
self::$_singleton == null) {
            
self::$_singleton = new AuthorizedState();
        }
        return 
self::$_singleton;
    }

    public function 
isAuthenticated()
    {
        return 
true;
    }

    public function 
nextState()
    {
        return 
UnauthorizedState::getInstance();
    }

    public function 
getMenu()
    {
        
$menu  '<a href="?mode=count">カウントアップ</a> | ';
        
$menu .= '<a href="?mode=reset">リセット</a> | ';
        
$menu .= '<a href="?mode=state">ログアウト</a>';

        return 
$menu;
    }

    public function 
__clone()
    {
        throw new 
LogicException('Clone is not allowed against [' get_class($this) . '].');
    }
}