for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
/**
* @file Guest.php
* @brief This file contains the Guest class.
* @details
* @author Filippo F. Fadda
*/
namespace Daikengo\User;
use Daikengo\Role\GuestRole;
use Daikengo\Permission\IPermission;
use Daikengo\Collection\RoleCollection;
* @brief This class represents an anonymous user.
* @nosubgrouping
final class Guest implements IUser {
* @brief This implementation returns always `null`.
* @return null
public function getId() {
return NULL;
}
* @brief This implementation returns always `false`.
* @param[in] string $id The id to match.
* @return bool
public function match($id) {
return FALSE;
* @copydoc IUser::has()
public function has(IPermission $permission) {
$role = new GuestRole();
$permissionReflection = new \ReflectionObject($permission);
if ($permissionReflection->hasMethod('checkForGuestRole')) { // If a method exists for the roleName...
// Gets the method.
$method = $permissionReflection->getMethod('checkForGuestRole');
$permission->setRole($role);
// Invokes the method.
return $method->invoke($permission);
else
* @brief This implementation returns always `true`.
public function isGuest() {
return TRUE;
public function isMember() {
* @brief This method is never called for this class, but in case it will return an empty collection.
* @return RoleCollection
public function getRoles() {
$roles = [];
return new RoleCollection('roles', $roles);