/**
  * Method that executes the Business Logic
  * and does all Controlling operations.
  *
  * @note Interaction is similar as a Controller
  *
  * @return void
  */
 public function execute()
 {
     if ($this->checkToken() === 1) {
         $this->setMessage('TokenStillValid');
     } elseif ($this->prepare()) {
         TokenManager::getInstance()->updateToken();
         $this->setMessage('TokenUpdated', ['token' => TokenManager::getInstance()->getToken()->getHash()]);
     } else {
         $this->setMessage('InvalidValue');
     }
 }
 /**
  * Method that executes the Business Logic
  * and does all Controlling operations.
  *
  * @note Interaction is similar as a Controller
  *
  * @return void
  */
 public function execute()
 {
     $this->setMessage('TokenInsertion', ['token' => TokenManager::getInstance()->createToken($this->getInstruction()->getInsertId())]);
 }
 /**
  * Check if the Token given by the `client` is valid or not.
  * If the `client` does'nt sent a token in query string also
  * the validation will return 0 (zero).
  *
  * If the Token isn't anymore valid (expired) will return -1
  * If is valid will return 1 (one)
  *
  * @return int (-1 : Expired, 0 : Invalid, 1 : Valid)
  */
 protected function checkToken()
 {
     if (TokenManager::getInstance()->getToken() === null) {
         TokenManager::getInstance()->setToken($this->getRequest()->query->get('token'));
     }
     return TokenManager::getInstance()->checkToken();
 }