link = $link; } /** * Evaluate a request. * * @param string $key Key supplied by the visitor. * @param bool $logged_in Whether the visitor has a session. * @param bool $authorized Whether the visitor may manage backups. * @param bool $has_package Whether a package is available. * @return string One of the class constants. */ public function evaluate( string $key, bool $logged_in, bool $authorized, bool $has_package ): string { if ( ! $this->link->matches( $key ) ) { return self::FORBIDDEN; } if ( ! $logged_in ) { return self::LOGIN; } if ( ! $authorized ) { return self::FORBIDDEN; } if ( ! $has_package ) { return self::MISSING; } return self::ALLOW; } }