public function generate() {
        
        $session = new Session();

        if(false === $session -> has('_token')) {
            $session -> add('_token', []);
        }

        $name  = TokenHash :: create(20, true, true, true);
        $value = TokenHash :: create(40, true, true, true);

        $session -> add('_token', [$name => $value]);
        $amount = count($session -> get('_token'));
        $limit  = Application :: get(['token', 'amount'], self :: TOKEN_AMOUNT);

        if($amount >= $limit) {
            $session -> add('_token', array_slice($session -> pull('_token'), $amount - $limit, null, true));
        }

        return (object) ['name' => $name, 'value' => $value];
    }
public function generate() {
        
        $session = new Session();

        if(false === $session -> has('_token')) {
            $session -> add('_token', []);
        }

        $name  = TokenHash :: create(20, true, true, true);
        $value = TokenHash :: create(40, true, true, true);

        $session -> add('_token', [$name => $value]);
        $amount = count($session -> get('_token'));
        $limit  = Application :: get(['token', 'amount'], self :: TOKEN_AMOUNT);

        if($amount >= $limit) {
            $session -> add('_token', array_slice($session -> pull('_token'), $amount - $limit, null, true));
        }

        return (object) ['name' => $name, 'value' => $value];
    }
public function generate ( ) { $ session = new Session ( ) ; if ( false === $ session -> has ( '_token' ) ) { $ session -> add ( '_token' , [ ] ) ; } $ name = TokenHash :: create ( 20 , true , true , true ) ; $ value = TokenHash :: create ( 40 , true , true , true ) ; $ session -> add ( '_token' , [ $ name => $ value ] ) ; $ amount = count ( $ session -> get ( '_token' ) ) ; $ limit = Application :: get ( [ 'token' , 'amount' ] , self :: TOKEN_AMOUNT ) ; if ( $ amount >= $ limit ) { $ session -> add ( '_token' , array_slice ( $ session -> pull ( '_token' ) , $ amount - $ limit , null , true ) ) ; } return ( object ) [ 'name' => $ name , 'value' => $ value ] ; }
Generates a new token and saves it into the session
@return object
Generates a new token and saves it into the session