I'm making SDK for a web platform, there is a client class which requires cookie to authorize and there is a function that gets auth token from cookie. So my question is: how to check if function was called outside of class. I need this because i want to protect this function with password and make it so if class called it, it would work without a password. Here is my code:
public function gettoken(?string password = ""): string{
//check if it's called inside of class
if (fromClass() == true){
//code that gets token
}
//if it's called outside of class
if ($password == $this->password){
//code that gets token
}
return "Incorrect password";
}