<?php $db_mock = array( 'token' => 'jfdfdkfldkhvmxhfuf', 'scope' => 'User.Profile' ); class API { private static $Token; public static function setToken($token) { self::$Token = $token; } public static function getToken() { return self::$Token; } } class Endpoint { public function __construct() { if(empty(API::getToken())) { throw new Exception('Invalid or undefined token.'); } } public function isToken($db_mock) { // replace with database logic if(in_array(API::getToken(), $db_mock)) { // run the logic for returning response for scope return true; } else { return false; } } } API::setToken('jfdfdkfldkhvmxhfuf'); $e = new Endpoint(); echo (int)$e->isToken($db_mock);
You have javascript disabled. You will not be able to edit any code.