authorization_method.php 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. <?php
  2. namespace phpnotify;
  3. /**
  4. * This class represents authorization method in the library.
  5. *
  6. * It represents authorization service, it may be overwrite by other class
  7. * which implements specified method, like user login or auth token.
  8. */
  9. abstract class authorization_method {
  10. /**
  11. * This return that authorization token is required or no.
  12. *
  13. * This is used to determinate that authorization header is required.
  14. * When it return true, then header would be added to the notify request.
  15. *
  16. * @return bool True when authorization token is required, false if not.
  17. */
  18. public abstract function is_header_required(): bool;
  19. /**
  20. * This return content of the authorization header.
  21. *
  22. * This return content of the authorization header, or null when header
  23. * is not required. Default return null.
  24. *
  25. * @return ?string Return content of the authorization header or null
  26. * when it is not required.
  27. */
  28. public function header_content(): string {
  29. return '';
  30. }
  31. /**
  32. * This return name of the authorization header.
  33. *
  34. * This return name of the authorization header. Default return
  35. * 'Authorization' which is standard name of that header. But it could
  36. * be changed by overwriting that function.
  37. *
  38. * @return string Name of the authorization header.
  39. */
  40. public function header_name(): string {
  41. return 'Authorization';
  42. }
  43. }