for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
declare(strict_types=1);
/**
* Saito - The Threaded Web Forum
*
* @copyright Copyright (c) the Saito Project Developers
* @link https://github.com/Schlaefer/Saito
* @license http://opensource.org/licenses/MIT
*/
namespace Saito\User\Permission;
use Saito\User\ForumsUserInterface;
* Resource Access Identity
class ResourceAI
{
/** @var string role */
protected $role = null;
/** @var int user-ID */
protected $userId = null;
/** @var ForumsUserInterface User to check against */
protected $user = null;
* Get the user which requests the permission
* @return ForumsUserInterface|null
public function getUser(): ?ForumsUserInterface
return $this->user;
}
* Get owner-ID of the resource
* @return int|null
public function getOwner(): ?int
return $this->userId;
* Get owner of the resource
* @return string|null
public function getRole(): ?string
return $this->role;
* Set a user which requests the permission
* @param ForumsUserInterface $user The user.
* @return self
public function asUser(ForumsUserInterface $user): self
$this->user = $user;
return $this;
* Set owner role
* @param string $role Owner's role
public function onRole(string $role): self
$this->role = $role;
* Set owner identity
* @param int $userId Owner's user-ID
public function onOwner(int $userId): self
$this->userId = $userId;