Files
appwrite/src/Audit/Adapter.php
T
eldadfux 35680bbae9 Run PHP-CS-FIXER to make sure
code is consisted with PSR-1 + PSR-2
2019-09-06 20:04:26 +03:00

94 lines
1.8 KiB
PHP

<?php
namespace Audit;
use Exception;
abstract class Adapter
{
protected $namespace = '';
/**
* Set Namespace.
*
* Set namespace to divide different scope of data sets
*
* @param $namespace
*
* @throws Exception
*
* @return bool
*/
public function setNamespace($namespace)
{
if (empty($namespace)) {
throw new Exception('Missing namespace');
}
$this->namespace = $namespace;
return true;
}
/**
* Get Namespace.
*
* Get namespace of current set scope
*
* @throws Exception
*
* @return string
*/
public function getNamespace()
{
if (empty($this->namespace)) {
throw new Exception('Missing namespace');
}
return $this->namespace;
}
/**
* Log.
*
* Add specific event log
*
* @param int $userId
* @param int $userType
* @param string $event
* @param string $resource
* @param string $userAgent
* @param string $ip
* @param string $location
* @param array $data
*
* @return
*/
abstract public function log($userId, $userType, $event, $resource, $userAgent, $ip, $location, $data);
/**
* Get All Logs By User.
*
* Get all user logs
*
* @param int $userId
* @param int $userType
*
* @return mixed
*/
abstract public function getLogsByUser($userId, $userType);
/**
* Get All Logs By User and Actions.
*
* Get all user logs by given action names
*
* @param int $userId
* @param int $userType
* @param array $actions
*
* @return mixed
*/
abstract public function getLogsByUserAndActions($userId, $userType, array $actions);
}