| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657 |
- <?php
- namespace phpnotify;
- /**
- * This could be used to store authorization method in the class.
- *
- * That class helps other classes storing authorization method, which is
- * implemented in more than one class.
- */
- class authorization_store {
- /**
- * This variable store current authorization method.
- * @var authorization_method
- */
- private authorization_method $method;
- /**
- * This initialize new aithorization part of class. It is protected.
- *
- * This function initialize authorization store. When any method is not
- * provided, then it use default empty authorization. Method could be
- * given there, for example when it is used by class, which is created
- * by class which also store authorization. It is protected, because it
- * would not being used as autonomous class.
- *
- * @param ?authorization_method Default method of authorization.
- */
- protected function __construct(?authorization_method $method = null) {
- if ($method === null) {
- $method = new empty_authorization();
- }
- $this->method = $method;
- }
- /**
- * That function return current setup access authorization method.
- *
- * @return authorization_method Current authorization method.
- */
- public function get_access_method(): authorization_method {
- return $this->method;
- }
-
- /**
- * This set new access method to use in the requests.
- *
- * @param authorization_method New method of the authorization.
- *
- * @return object Self to chain loading.
- */
- public function access_method(authorization_method $method): object {
- $this->method = $method;
- return $this;
- }
- }
|